home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 49 6e 69 74 69 61 | 6c 20 65 6e 76 69 72 6f |% Initia|l enviro|
|00000010| 6e 6d 65 6e 74 0a 0a 25 | 5c 76 66 69 6c 6c 5c 65 |nment..%|\vfill\e|
|00000020| 6a 65 63 74 0a 5c 63 68 | 61 70 74 65 72 7b 53 74 |ject.\ch|apter{St|
|00000030| 61 6e 64 61 72 64 20 70 | 72 6f 63 65 64 75 72 65 |andard p|rocedure|
|00000040| 73 7d 0a 5c 6c 61 62 65 | 6c 7b 69 6e 69 74 69 61 |s}.\labe|l{initia|
|00000050| 6c 65 6e 76 7d 0a 5c 6c | 61 62 65 6c 7b 62 75 69 |lenv}.\l|abel{bui|
|00000060| 6c 74 69 6e 63 68 61 70 | 74 65 72 7d 0a 0a 5c 6d |ltinchap|ter}..\m|
|00000070| 61 69 6e 69 6e 64 65 78 | 7b 69 6e 69 74 69 61 6c |ainindex|{initial|
|00000080| 20 65 6e 76 69 72 6f 6e | 6d 65 6e 74 7d 0a 5c 6d | environ|ment}.\m|
|00000090| 61 69 6e 69 6e 64 65 78 | 7b 74 6f 70 20 6c 65 76 |ainindex|{top lev|
|000000a0| 65 6c 20 65 6e 76 69 72 | 6f 6e 6d 65 6e 74 7d 0a |el envir|onment}.|
|000000b0| 0a 54 68 69 73 20 63 68 | 61 70 74 65 72 20 64 65 |.This ch|apter de|
|000000c0| 73 63 72 69 62 65 73 20 | 53 63 68 65 6d 65 27 73 |scribes |Scheme's|
|000000d0| 20 62 75 69 6c 74 2d 69 | 6e 20 70 72 6f 63 65 64 | built-i|n proced|
|000000e0| 75 72 65 73 2e 20 20 54 | 68 65 20 69 6e 69 74 69 |ures. T|he initi|
|000000f0| 61 6c 20 28 6f 72 0a 60 | 60 74 6f 70 20 6c 65 76 |al (or.`|`top lev|
|00000100| 65 6c 27 27 29 20 53 63 | 68 65 6d 65 20 65 6e 76 |el'') Sc|heme env|
|00000110| 69 72 6f 6e 6d 65 6e 74 | 20 73 74 61 72 74 73 20 |ironment| starts |
|00000120| 6f 75 74 20 77 69 74 68 | 20 61 20 6e 75 6d 62 65 |out with| a numbe|
|00000130| 72 20 6f 66 20 76 61 72 | 69 61 62 6c 65 73 0a 62 |r of var|iables.b|
|00000140| 6f 75 6e 64 20 74 6f 20 | 6c 6f 63 61 74 69 6f 6e |ound to |location|
|00000150| 73 20 63 6f 6e 74 61 69 | 6e 69 6e 67 20 75 73 65 |s contai|ning use|
|00000160| 66 75 6c 20 76 61 6c 75 | 65 73 2c 20 6d 6f 73 74 |ful valu|es, most|
|00000170| 20 6f 66 20 77 68 69 63 | 68 20 61 72 65 20 70 72 | of whic|h are pr|
|00000180| 69 6d 69 74 69 76 65 0a | 70 72 6f 63 65 64 75 72 |imitive.|procedur|
|00000190| 65 73 20 74 68 61 74 20 | 6d 61 6e 69 70 75 6c 61 |es that |manipula|
|000001a0| 74 65 20 64 61 74 61 2e | 20 20 46 6f 72 20 65 78 |te data.| For ex|
|000001b0| 61 6d 70 6c 65 2c 20 74 | 68 65 20 76 61 72 69 61 |ample, t|he varia|
|000001c0| 62 6c 65 20 5c 69 64 65 | 7b 61 62 73 7d 20 69 73 |ble \ide|{abs} is|
|000001d0| 0a 62 6f 75 6e 64 20 74 | 6f 20 28 61 20 6c 6f 63 |.bound t|o (a loc|
|000001e0| 61 74 69 6f 6e 20 69 6e | 69 74 69 61 6c 6c 79 20 |ation in|itially |
|000001f0| 63 6f 6e 74 61 69 6e 69 | 6e 67 29 20 61 20 70 72 |containi|ng) a pr|
|00000200| 6f 63 65 64 75 72 65 20 | 6f 66 20 6f 6e 65 20 61 |ocedure |of one a|
|00000210| 72 67 75 6d 65 6e 74 0a | 74 68 61 74 20 63 6f 6d |rgument.|that com|
|00000220| 70 75 74 65 73 20 74 68 | 65 20 61 62 73 6f 6c 75 |putes th|e absolu|
|00000230| 74 65 20 76 61 6c 75 65 | 20 6f 66 20 61 20 6e 75 |te value| of a nu|
|00000240| 6d 62 65 72 2c 20 61 6e | 64 20 74 68 65 20 76 61 |mber, an|d the va|
|00000250| 72 69 61 62 6c 65 20 5c | 69 64 65 7b 2b 7d 0a 69 |riable \|ide{+}.i|
|00000260| 73 20 62 6f 75 6e 64 20 | 74 6f 20 61 20 70 72 6f |s bound |to a pro|
|00000270| 63 65 64 75 72 65 20 74 | 68 61 74 20 63 6f 6d 70 |cedure t|hat comp|
|00000280| 75 74 65 73 20 73 75 6d | 73 2e 0a 0a 0a 5c 73 65 |utes sum|s....\se|
|00000290| 63 74 69 6f 6e 7b 42 6f | 6f 6c 65 61 6e 73 7d 0a |ction{Bo|oleans}.|
|000002a0| 5c 6c 61 62 65 6c 7b 62 | 6f 6f 6c 65 61 6e 73 65 |\label{b|ooleanse|
|000002b0| 63 74 69 6f 6e 7d 0a 0a | 54 68 65 20 73 74 61 6e |ction}..|The stan|
|000002c0| 64 61 72 64 20 62 6f 6f | 6c 65 61 6e 20 6f 62 6a |dard boo|lean obj|
|000002d0| 65 63 74 73 20 66 6f 72 | 20 74 72 75 65 20 61 6e |ects for| true an|
|000002e0| 64 20 66 61 6c 73 65 20 | 61 72 65 20 77 72 69 74 |d false |are writ|
|000002f0| 74 65 6e 20 61 73 0a 5c | 73 63 68 74 72 75 65 7b |ten as.\|schtrue{|
|00000300| 7d 20 61 6e 64 20 5c 73 | 63 68 66 61 6c 73 65 2e |} and \s|chfalse.|
|00000310| 5c 73 68 61 72 70 69 6e | 64 65 78 7b 74 7d 5c 73 |\sharpin|dex{t}\s|
|00000320| 68 61 72 70 69 6e 64 65 | 78 7b 66 7d 20 20 57 68 |harpinde|x{f} Wh|
|00000330| 61 74 20 72 65 61 6c 6c | 79 0a 6d 61 74 74 65 72 |at reall|y.matter|
|00000340| 73 2c 20 74 68 6f 75 67 | 68 2c 20 61 72 65 20 74 |s, thoug|h, are t|
|00000350| 68 65 20 6f 62 6a 65 63 | 74 73 20 74 68 61 74 20 |he objec|ts that |
|00000360| 74 68 65 20 53 63 68 65 | 6d 65 20 63 6f 6e 64 69 |the Sche|me condi|
|00000370| 74 69 6f 6e 61 6c 20 65 | 78 70 72 65 73 73 69 6f |tional e|xpressio|
|00000380| 6e 73 0a 28 5c 69 64 65 | 7b 69 66 7d 2c 20 5c 69 |ns.(\ide|{if}, \i|
|00000390| 64 65 7b 63 6f 6e 64 7d | 2c 20 5c 69 64 65 7b 61 |de{cond}|, \ide{a|
|000003a0| 6e 64 7d 2c 20 5c 69 64 | 65 7b 6f 72 7d 2c 20 5c |nd}, \id|e{or}, \|
|000003b0| 69 64 65 7b 64 6f 7d 29 | 20 74 72 65 61 74 20 61 |ide{do})| treat a|
|000003c0| 73 0a 74 72 75 65 5c 69 | 6e 64 65 78 7b 74 72 75 |s.true\i|ndex{tru|
|000003d0| 65 7d 20 6f 72 20 66 61 | 6c 73 65 5c 69 6e 64 65 |e} or fa|lse\inde|
|000003e0| 78 7b 66 61 6c 73 65 7d | 2e 20 20 54 68 65 20 70 |x{false}|. The p|
|000003f0| 68 72 61 73 65 20 60 60 | 61 20 74 72 75 65 20 76 |hrase ``|a true v|
|00000400| 61 6c 75 65 27 27 20 28 | 6f 72 0a 73 6f 6d 65 74 |alue'' (|or.somet|
|00000410| 69 6d 65 73 20 6a 75 73 | 74 20 60 60 74 72 75 65 |imes jus|t ``true|
|00000420| 27 27 29 20 6d 65 61 6e | 73 20 61 6e 79 20 6f 62 |'') mean|s any ob|
|00000430| 6a 65 63 74 20 74 72 65 | 61 74 65 64 20 61 73 20 |ject tre|ated as |
|00000440| 74 72 75 65 20 62 79 20 | 74 68 65 0a 63 6f 6e 64 |true by |the.cond|
|00000450| 69 74 69 6f 6e 61 6c 20 | 65 78 70 72 65 73 73 69 |itional |expressi|
|00000460| 6f 6e 73 2c 20 61 6e 64 | 20 74 68 65 20 70 68 72 |ons, and| the phr|
|00000470| 61 73 65 20 60 60 61 20 | 66 61 6c 73 65 20 76 61 |ase ``a |false va|
|00000480| 6c 75 65 27 27 20 28 6f | 72 20 60 60 66 61 6c 73 |lue'' (o|r ``fals|
|00000490| 65 27 27 29 0a 6d 65 61 | 6e 73 20 61 6e 79 20 6f |e'').mea|ns any o|
|000004a0| 62 6a 65 63 74 20 74 72 | 65 61 74 65 64 20 61 73 |bject tr|eated as|
|000004b0| 20 66 61 6c 73 65 20 62 | 79 20 74 68 65 20 63 6f | false b|y the co|
|000004c0| 6e 64 69 74 69 6f 6e 61 | 6c 20 65 78 70 72 65 73 |nditiona|l expres|
|000004d0| 73 69 6f 6e 73 2e 0a 0a | 5c 76 65 73 74 20 4f 66 |sions...|\vest Of|
|000004e0| 20 61 6c 6c 20 74 68 65 | 20 73 74 61 6e 64 61 72 | all the| standar|
|000004f0| 64 20 53 63 68 65 6d 65 | 20 76 61 6c 75 65 73 2c |d Scheme| values,|
|00000500| 20 6f 6e 6c 79 20 5c 73 | 63 68 66 61 6c 73 65 7b | only \s|chfalse{|
|00000510| 7d 20 61 6e 64 20 74 68 | 65 20 65 6d 70 74 79 20 |} and th|e empty |
|00000520| 6c 69 73 74 5c 69 6e 64 | 65 78 7b 65 6d 70 74 79 |list\ind|ex{empty|
|00000530| 20 6c 69 73 74 7d 0a 63 | 6f 75 6e 74 20 61 73 20 | list}.c|ount as |
|00000540| 66 61 6c 73 65 20 69 6e | 20 63 6f 6e 64 69 74 69 |false in| conditi|
|00000550| 6f 6e 61 6c 20 65 78 70 | 72 65 73 73 69 6f 6e 73 |onal exp|ressions|
|00000560| 2e 20 20 45 76 65 72 79 | 74 68 69 6e 67 20 65 6c |. Every|thing el|
|00000570| 73 65 2c 20 69 6e 63 6c | 75 64 69 6e 67 0a 5c 73 |se, incl|uding.\s|
|00000580| 63 68 74 72 75 65 2c 20 | 70 61 69 72 73 2c 20 73 |chtrue, |pairs, s|
|00000590| 79 6d 62 6f 6c 73 2c 20 | 6e 75 6d 62 65 72 73 2c |ymbols, |numbers,|
|000005a0| 20 73 74 72 69 6e 67 73 | 2c 20 76 65 63 74 6f 72 | strings|, vector|
|000005b0| 73 2c 20 61 6e 64 20 70 | 72 6f 63 65 64 75 72 65 |s, and p|rocedure|
|000005c0| 73 2c 0a 63 6f 75 6e 74 | 73 20 61 73 20 74 72 75 |s,.count|s as tru|
|000005d0| 65 2e 0a 0a 5c 76 65 73 | 74 20 54 68 65 20 65 6d |e...\ves|t The em|
|000005e0| 70 74 79 20 6c 69 73 74 | 20 63 6f 75 6e 74 73 20 |pty list| counts |
|000005f0| 61 73 20 66 61 6c 73 65 | 20 66 6f 72 20 63 6f 6d |as false| for com|
|00000600| 70 61 74 69 62 69 6c 69 | 74 79 20 77 69 74 68 20 |patibili|ty with |
|00000610| 65 78 69 73 74 69 6e 67 | 20 70 72 6f 67 72 61 6d |existing| program|
|00000620| 73 0a 61 6e 64 20 69 6d | 70 6c 65 6d 65 6e 74 61 |s.and im|plementa|
|00000630| 74 69 6f 6e 73 20 74 68 | 61 74 20 61 73 73 75 6d |tions th|at assum|
|00000640| 65 20 74 68 69 73 20 74 | 6f 20 62 65 20 74 68 65 |e this t|o be the|
|00000650| 20 63 61 73 65 2e 0a 0a | 5c 76 65 73 74 20 50 72 | case...|\vest Pr|
|00000660| 6f 67 72 61 6d 6d 65 72 | 73 20 61 63 63 75 73 74 |ogrammer|s accust|
|00000670| 6f 6d 65 64 20 74 6f 20 | 6f 74 68 65 72 20 64 69 |omed to |other di|
|00000680| 61 6c 65 63 74 73 20 6f | 66 20 4c 69 73 70 20 73 |alects o|f Lisp s|
|00000690| 68 6f 75 6c 64 20 62 65 | 77 61 72 65 20 74 68 61 |hould be|ware tha|
|000006a0| 74 0a 53 63 68 65 6d 65 | 20 64 69 73 74 69 6e 67 |t.Scheme| disting|
|000006b0| 75 69 73 68 65 73 20 5c | 73 63 68 66 61 6c 73 65 |uishes \|schfalse|
|000006c0| 7b 7d 20 61 6e 64 20 74 | 68 65 20 65 6d 70 74 79 |{} and t|he empty|
|000006d0| 20 6c 69 73 74 20 66 72 | 6f 6d 20 74 68 65 20 73 | list fr|om the s|
|000006e0| 79 6d 62 6f 6c 20 5c 69 | 64 65 7b 6e 69 6c 7d 2e |ymbol \i|de{nil}.|
|000006f0| 0a 0a 5c 76 65 73 74 20 | 42 6f 6f 6c 65 61 6e 20 |..\vest |Boolean |
|00000700| 63 6f 6e 73 74 61 6e 74 | 73 20 65 76 61 6c 75 61 |constant|s evalua|
|00000710| 74 65 20 74 6f 20 74 68 | 65 6d 73 65 6c 76 65 73 |te to th|emselves|
|00000720| 2c 20 73 6f 20 74 68 65 | 79 20 64 6f 6e 27 74 20 |, so the|y don't |
|00000730| 6e 65 65 64 20 74 6f 20 | 62 65 20 71 75 6f 74 65 |need to |be quote|
|00000740| 64 0a 69 6e 20 70 72 6f | 67 72 61 6d 73 2e 0a 0a |d.in pro|grams...|
|00000750| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 5c |\begin{s|cheme}.\|
|00000760| 73 63 68 74 72 75 65 20 | 20 20 20 20 20 20 20 20 |schtrue | |
|00000770| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 0a 5c 73 |\ev \sc|htrue.\s|
|00000780| 63 68 66 61 6c 73 65 20 | 20 20 20 20 20 20 20 5c |chfalse | \|
|00000790| 65 76 20 20 5c 73 63 68 | 66 61 6c 73 65 0a 27 5c |ev \sch|false.'\|
|000007a0| 73 63 68 66 61 6c 73 65 | 20 20 20 20 20 20 20 5c |schfalse| \|
|000007b0| 65 76 20 20 5c 73 63 68 | 66 61 6c 73 65 25 0a 5c |ev \sch|false%.\|
|000007c0| 65 6e 64 7b 73 63 68 65 | 6d 65 7d 0a 0a 0a 5c 62 |end{sche|me}...\b|
|000007d0| 65 67 69 6e 7b 65 6e 74 | 72 79 7d 7b 25 0a 5c 70 |egin{ent|ry}{%.\p|
|000007e0| 72 6f 74 6f 7b 6e 6f 74 | 7d 7b 20 6f 62 6a 7d 7b |roto{not|}{ obj}{|
|000007f0| 65 73 73 65 6e 74 69 61 | 6c 20 70 72 6f 63 65 64 |essentia|l proced|
|00000800| 75 72 65 7d 7d 0a 0a 5c | 69 64 65 7b 4e 6f 74 7d |ure}}..\|ide{Not}|
|00000810| 20 72 65 74 75 72 6e 73 | 20 5c 73 63 68 74 72 75 | returns| \schtru|
|00000820| 65 7b 7d 20 69 66 20 5c | 76 61 72 7b 6f 62 6a 7d |e{} if \|var{obj}|
|00000830| 20 69 73 20 66 61 6c 73 | 65 2c 20 61 6e 64 20 72 | is fals|e, and r|
|00000840| 65 74 75 72 6e 73 0a 5c | 73 63 68 66 61 6c 73 65 |eturns.\|schfalse|
|00000850| 7b 7d 20 6f 74 68 65 72 | 77 69 73 65 2e 0a 0a 5c |{} other|wise...\|
|00000860| 62 65 67 69 6e 7b 73 63 | 68 65 6d 65 7d 0a 28 6e |begin{sc|heme}.(n|
|00000870| 6f 74 20 5c 73 63 68 74 | 72 75 65 29 20 20 20 5c |ot \scht|rue) \|
|00000880| 65 76 20 20 5c 73 63 68 | 66 61 6c 73 65 0a 28 6e |ev \sch|false.(n|
|00000890| 6f 74 20 33 29 20 20 20 | 20 20 20 20 20 20 20 5c |ot 3) | \|
|000008a0| 65 76 20 20 5c 73 63 68 | 66 61 6c 73 65 0a 28 6e |ev \sch|false.(n|
|000008b0| 6f 74 20 28 6c 69 73 74 | 20 33 29 29 20 20 20 5c |ot (list| 3)) \|
|000008c0| 65 76 20 20 5c 73 63 68 | 66 61 6c 73 65 0a 28 6e |ev \sch|false.(n|
|000008d0| 6f 74 20 5c 73 63 68 66 | 61 6c 73 65 29 20 20 5c |ot \schf|alse) \|
|000008e0| 65 76 20 20 5c 73 63 68 | 74 72 75 65 0a 28 6e 6f |ev \sch|true.(no|
|000008f0| 74 20 27 28 29 29 20 20 | 20 20 20 20 20 20 5c 65 |t '()) | \e|
|00000900| 76 20 20 5c 73 63 68 74 | 72 75 65 0a 28 6e 6f 74 |v \scht|rue.(not|
|00000910| 20 28 6c 69 73 74 29 29 | 20 20 20 20 20 5c 65 76 | (list))| \ev|
|00000920| 20 20 5c 73 63 68 74 72 | 75 65 0a 28 6e 6f 74 20 | \schtr|ue.(not |
|00000930| 27 6e 69 6c 29 20 20 20 | 20 20 20 20 5c 65 76 20 |'nil) | \ev |
|00000940| 20 5c 73 63 68 66 61 6c | 73 65 25 0a 5c 65 6e 64 | \schfal|se%.\end|
|00000950| 7b 73 63 68 65 6d 65 7d | 0a 0a 5c 65 6e 64 7b 65 |{scheme}|..\end{e|
|00000960| 6e 74 72 79 7d 0a 0a 0a | 5c 62 65 67 69 6e 7b 65 |ntry}...|\begin{e|
|00000970| 6e 74 72 79 7d 7b 25 0a | 5c 70 72 6f 74 6f 7b 62 |ntry}{%.|\proto{b|
|00000980| 6f 6f 6c 65 61 6e 3f 7d | 7b 20 6f 62 6a 7d 7b 65 |oolean?}|{ obj}{e|
|00000990| 73 73 65 6e 74 69 61 6c | 20 70 72 6f 63 65 64 75 |ssential| procedu|
|000009a0| 72 65 7d 7d 0a 0a 5c 69 | 64 65 7b 42 6f 6f 6c 65 |re}}..\i|de{Boole|
|000009b0| 61 6e 3f 7d 20 72 65 74 | 75 72 6e 73 20 5c 73 63 |an?} ret|urns \sc|
|000009c0| 68 74 72 75 65 7b 7d 20 | 69 66 20 5c 76 61 72 7b |htrue{} |if \var{|
|000009d0| 6f 62 6a 7d 20 69 73 20 | 65 69 74 68 65 72 20 5c |obj} is |either \|
|000009e0| 73 63 68 74 72 75 65 7b | 7d 20 6f 72 0a 5c 73 63 |schtrue{|} or.\sc|
|000009f0| 68 66 61 6c 73 65 7b 7d | 20 61 6e 64 20 72 65 74 |hfalse{}| and ret|
|00000a00| 75 72 6e 73 20 5c 73 63 | 68 66 61 6c 73 65 7b 7d |urns \sc|hfalse{}|
|00000a10| 20 6f 74 68 65 72 77 69 | 73 65 2e 0a 0a 5c 62 65 | otherwi|se...\be|
|00000a20| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 62 6f 6f |gin{sche|me}.(boo|
|00000a30| 6c 65 61 6e 3f 20 5c 73 | 63 68 66 61 6c 73 65 29 |lean? \s|chfalse)|
|00000a40| 20 20 5c 65 76 20 20 5c | 73 63 68 74 72 75 65 0a | \ev \|schtrue.|
|00000a50| 28 62 6f 6f 6c 65 61 6e | 3f 20 30 29 20 20 20 20 |(boolean|? 0) |
|00000a60| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 73 63 68 66 | \e|v \schf|
|00000a70| 61 6c 73 65 25 0a 5c 65 | 6e 64 7b 73 63 68 65 6d |alse%.\e|nd{schem|
|00000a80| 65 7d 0a 0a 5c 65 6e 64 | 7b 65 6e 74 72 79 7d 0a |e}..\end|{entry}.|
|00000a90| 0a 20 0a 5c 73 65 63 74 | 69 6f 6e 7b 45 71 75 69 |. .\sect|ion{Equi|
|00000aa0| 76 61 6c 65 6e 63 65 20 | 70 72 65 64 69 63 61 74 |valence |predicat|
|00000ab0| 65 73 7d 0a 5c 6c 61 62 | 65 6c 7b 65 71 75 69 76 |es}.\lab|el{equiv|
|00000ac0| 61 6c 65 6e 63 65 73 65 | 63 74 69 6f 6e 7d 0a 0a |alencese|ction}..|
|00000ad0| 41 20 5c 64 65 66 69 6e | 69 6e 67 7b 70 72 65 64 |A \defin|ing{pred|
|00000ae0| 69 63 61 74 65 7d 20 69 | 73 20 61 20 70 72 6f 63 |icate} i|s a proc|
|00000af0| 65 64 75 72 65 20 74 68 | 61 74 20 61 6c 77 61 79 |edure th|at alway|
|00000b00| 73 20 72 65 74 75 72 6e | 73 20 61 20 62 6f 6f 6c |s return|s a bool|
|00000b10| 65 61 6e 0a 76 61 6c 75 | 65 20 28 5c 73 63 68 74 |ean.valu|e (\scht|
|00000b20| 72 75 65 7b 7d 20 6f 72 | 20 5c 73 63 68 66 61 6c |rue{} or| \schfal|
|00000b30| 73 65 29 2e 20 20 41 6e | 20 5c 64 65 66 69 6e 69 |se). An| \defini|
|00000b40| 6e 67 7b 65 71 75 69 76 | 61 6c 65 6e 63 65 20 70 |ng{equiv|alence p|
|00000b50| 72 65 64 69 63 61 74 65 | 7d 20 69 73 0a 74 68 65 |redicate|} is.the|
|00000b60| 20 63 6f 6d 70 75 74 61 | 74 69 6f 6e 61 6c 20 61 | computa|tional a|
|00000b70| 6e 61 6c 6f 67 75 65 20 | 6f 66 20 61 20 6d 61 74 |nalogue |of a mat|
|00000b80| 68 65 6d 61 74 69 63 61 | 6c 20 65 71 75 69 76 61 |hematica|l equiva|
|00000b90| 6c 65 6e 63 65 20 72 65 | 6c 61 74 69 6f 6e 20 28 |lence re|lation (|
|00000ba0| 69 74 20 69 73 0a 73 79 | 6d 6d 65 74 72 69 63 2c |it is.sy|mmetric,|
|00000bb0| 20 72 65 66 6c 65 78 69 | 76 65 2c 20 61 6e 64 20 | reflexi|ve, and |
|00000bc0| 74 72 61 6e 73 69 74 69 | 76 65 29 2e 20 20 4f 66 |transiti|ve). Of|
|00000bd0| 20 74 68 65 20 65 71 75 | 69 76 61 6c 65 6e 63 65 | the equ|ivalence|
|00000be0| 20 70 72 65 64 69 63 61 | 74 65 73 0a 64 65 73 63 | predica|tes.desc|
|00000bf0| 72 69 62 65 64 20 69 6e | 20 74 68 69 73 20 73 65 |ribed in| this se|
|00000c00| 63 74 69 6f 6e 2c 20 5c | 69 64 65 7b 65 71 3f 7d |ction, \|ide{eq?}|
|00000c10| 5c 20 69 73 20 74 68 65 | 20 66 69 6e 65 73 74 20 |\ is the| finest |
|00000c20| 6f 72 20 6d 6f 73 74 0a | 64 69 73 63 72 69 6d 69 |or most.|discrimi|
|00000c30| 6e 61 74 69 6e 67 2c 20 | 61 6e 64 20 5c 69 64 65 |nating, |and \ide|
|00000c40| 7b 65 71 75 61 6c 3f 7d | 5c 20 69 73 20 74 68 65 |{equal?}|\ is the|
|00000c50| 20 63 6f 61 72 73 65 73 | 74 2e 20 20 5c 69 64 65 | coarses|t. \ide|
|00000c60| 7b 45 71 76 3f 7d 5c 20 | 69 73 0a 73 6c 69 67 68 |{Eqv?}\ |is.sligh|
|00000c70| 74 6c 79 20 6c 65 73 73 | 20 64 69 73 63 72 69 6d |tly less| discrim|
|00000c80| 69 6e 61 74 69 6e 67 20 | 74 68 61 6e 20 5c 69 64 |inating |than \id|
|00000c90| 65 7b 65 71 3f 7d 2e 20 | 20 5c 74 6f 64 6f 7b 50 |e{eq?}. | \todo{P|
|00000ca0| 69 74 6d 61 6e 20 64 6f | 65 73 6e 27 74 20 6c 69 |itman do|esn't li|
|00000cb0| 6b 65 0a 74 68 69 73 20 | 70 61 72 61 67 72 61 70 |ke.this |paragrap|
|00000cc0| 68 2e 20 20 4c 69 66 74 | 20 74 68 65 20 64 69 73 |h. Lift| the dis|
|00000cd0| 63 75 73 73 69 6f 6e 20 | 66 72 6f 6d 20 74 68 65 |cussion |from the|
|00000ce0| 20 4d 61 63 6c 69 73 70 | 20 6d 61 6e 75 61 6c 2e | Maclisp| manual.|
|00000cf0| 20 20 45 78 70 6c 61 69 | 6e 0a 77 68 79 20 74 68 | Explai|n.why th|
|00000d00| 65 72 65 27 73 20 6d 6f | 72 65 20 74 68 61 6e 20 |ere's mo|re than |
|00000d10| 6f 6e 65 20 70 72 65 64 | 69 63 61 74 65 2e 7d 0a |one pred|icate.}.|
|00000d20| 0a 0a 5c 62 65 67 69 6e | 7b 65 6e 74 72 79 7d 7b |..\begin|{entry}{|
|00000d30| 25 0a 5c 70 72 6f 74 6f | 7b 65 71 76 3f 7d 7b 20 |%.\proto|{eqv?}{ |
|00000d40| 5c 76 61 72 69 7b 6f 62 | 6a 7d 20 5c 76 61 72 69 |\vari{ob|j} \vari|
|00000d50| 69 7b 6f 62 6a 7d 7d 7b | 65 73 73 65 6e 74 69 61 |i{obj}}{|essentia|
|00000d60| 6c 20 70 72 6f 63 65 64 | 75 72 65 7d 7d 0a 0a 54 |l proced|ure}}..T|
|00000d70| 68 65 20 5c 69 64 65 7b | 65 71 76 3f 7d 20 70 72 |he \ide{|eqv?} pr|
|00000d80| 6f 63 65 64 75 72 65 20 | 64 65 66 69 6e 65 73 20 |ocedure |defines |
|00000d90| 61 20 75 73 65 66 75 6c | 20 65 71 75 69 76 61 6c |a useful| equival|
|00000da0| 65 6e 63 65 20 72 65 6c | 61 74 69 6f 6e 20 6f 6e |ence rel|ation on|
|00000db0| 20 6f 62 6a 65 63 74 73 | 2e 0a 42 72 69 65 66 6c | objects|..Briefl|
|00000dc0| 79 2c 20 69 74 20 72 65 | 74 75 72 6e 73 20 5c 73 |y, it re|turns \s|
|00000dd0| 63 68 74 72 75 65 7b 7d | 20 69 66 20 5c 76 61 72 |chtrue{}| if \var|
|00000de0| 69 7b 6f 62 6a 7d 20 61 | 6e 64 20 5c 76 61 72 69 |i{obj} a|nd \vari|
|00000df0| 69 7b 6f 62 6a 7d 20 73 | 68 6f 75 6c 64 0a 6e 6f |i{obj} s|hould.no|
|00000e00| 72 6d 61 6c 6c 79 20 62 | 65 20 72 65 67 61 72 64 |rmally b|e regard|
|00000e10| 65 64 20 61 73 20 74 68 | 65 20 73 61 6d 65 20 6f |ed as th|e same o|
|00000e20| 62 6a 65 63 74 2e 20 20 | 54 68 69 73 20 72 65 6c |bject. |This rel|
|00000e30| 61 74 69 6f 6e 20 69 73 | 20 6c 65 66 74 20 73 6c |ation is| left sl|
|00000e40| 69 67 68 74 6c 79 0a 6f | 70 65 6e 20 74 6f 20 69 |ightly.o|pen to i|
|00000e50| 6e 74 65 72 70 72 65 74 | 61 74 69 6f 6e 2c 20 62 |nterpret|ation, b|
|00000e60| 75 74 20 74 68 65 20 66 | 6f 6c 6c 6f 77 69 6e 67 |ut the f|ollowing|
|00000e70| 20 70 61 72 74 69 61 6c | 20 73 70 65 63 69 66 69 | partial| specifi|
|00000e80| 63 61 74 69 6f 6e 20 6f | 66 0a 5c 69 64 65 7b 65 |cation o|f.\ide{e|
|00000e90| 71 76 3f 7d 20 68 6f 6c | 64 73 20 66 6f 72 20 61 |qv?} hol|ds for a|
|00000ea0| 6c 6c 20 69 6d 70 6c 65 | 6d 65 6e 74 61 74 69 6f |ll imple|mentatio|
|00000eb0| 6e 73 20 6f 66 20 53 63 | 68 65 6d 65 2e 0a 0a 54 |ns of Sc|heme...T|
|00000ec0| 68 65 20 5c 69 64 65 7b | 65 71 76 3f 7d 20 70 72 |he \ide{|eqv?} pr|
|00000ed0| 6f 63 65 64 75 72 65 20 | 72 65 74 75 72 6e 73 20 |ocedure |returns |
|00000ee0| 5c 73 63 68 74 72 75 65 | 7b 7d 20 69 66 3a 0a 0a |\schtrue|{} if:..|
|00000ef0| 5c 62 65 67 69 6e 7b 69 | 74 65 6d 69 7a 65 7d 0a |\begin{i|temize}.|
|00000f00| 5c 69 74 65 6d 20 5c 76 | 61 72 69 7b 6f 62 6a 7d |\item \v|ari{obj}|
|00000f10| 20 61 6e 64 20 5c 76 61 | 72 69 69 7b 6f 62 6a 7d | and \va|rii{obj}|
|00000f20| 20 61 72 65 20 62 6f 74 | 68 20 5c 73 63 68 74 72 | are bot|h \schtr|
|00000f30| 75 65 7b 7d 20 6f 72 20 | 62 6f 74 68 20 5c 73 63 |ue{} or |both \sc|
|00000f40| 68 66 61 6c 73 65 2e 0a | 0a 5c 69 74 65 6d 20 5c |hfalse..|.\item \|
|00000f50| 76 61 72 69 7b 6f 62 6a | 7d 20 61 6e 64 20 5c 76 |vari{obj|} and \v|
|00000f60| 61 72 69 69 7b 6f 62 6a | 7d 20 61 72 65 20 62 6f |arii{obj|} are bo|
|00000f70| 74 68 20 73 79 6d 62 6f | 6c 73 20 61 6e 64 0a 0a |th symbo|ls and..|
|00000f80| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 28 |\begin{s|cheme}.(|
|00000f90| 73 74 72 69 6e 67 3d 3f | 20 28 73 79 6d 62 6f 6c |string=?| (symbol|
|00000fa0| 2d 3e 73 74 72 69 6e 67 | 20 6f 62 6a 31 29 0a 20 |->string| obj1). |
|00000fb0| 20 20 20 20 20 20 20 20 | 20 28 73 79 6d 62 6f 6c | | (symbol|
|00000fc0| 2d 3e 73 74 72 69 6e 67 | 20 6f 62 6a 32 29 29 0a |->string| obj2)).|
|00000fd0| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 74 72 75 | \ev | \schtru|
|00000fe0| 65 25 0a 5c 65 6e 64 7b | 73 63 68 65 6d 65 7d 0a |e%.\end{|scheme}.|
|00000ff0| 0a 5c 62 65 67 69 6e 7b | 6e 6f 74 65 7d 20 0a 54 |.\begin{|note} .T|
|00001000| 68 69 73 20 61 73 73 75 | 6d 65 73 20 74 68 61 74 |his assu|mes that|
|00001010| 20 6e 65 69 74 68 65 72 | 20 5c 76 61 72 69 7b 6f | neither| \vari{o|
|00001020| 62 6a 7d 20 6e 6f 72 20 | 5c 76 61 72 69 69 7b 6f |bj} nor |\varii{o|
|00001030| 62 6a 7d 20 69 73 20 61 | 6e 20 60 60 75 6e 69 6e |bj} is a|n ``unin|
|00001040| 74 65 72 6e 65 64 0a 73 | 79 6d 62 6f 6c 27 27 20 |terned.s|ymbol'' |
|00001050| 61 73 20 61 6c 6c 75 64 | 65 64 20 74 6f 20 69 6e |as allud|ed to in|
|00001060| 20 73 65 63 74 69 6f 6e | 7e 5c 72 65 66 7b 73 79 | section|~\ref{sy|
|00001070| 6d 62 6f 6c 73 65 63 74 | 69 6f 6e 7d 2e 20 20 54 |mbolsect|ion}. T|
|00001080| 68 69 73 20 72 65 70 6f | 72 74 20 64 6f 65 73 0a |his repo|rt does.|
|00001090| 6e 6f 74 20 70 72 65 73 | 75 6d 65 20 74 6f 20 73 |not pres|ume to s|
|000010a0| 70 65 63 69 66 79 20 74 | 68 65 20 62 65 68 61 76 |pecify t|he behav|
|000010b0| 69 6f 72 20 6f 66 20 5c | 69 64 65 7b 65 71 76 3f |ior of \|ide{eqv?|
|000010c0| 7d 20 6f 6e 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 |} on imp|lementat|
|000010d0| 69 6f 6e 2d 64 65 70 65 | 6e 64 65 6e 74 0a 65 78 |ion-depe|ndent.ex|
|000010e0| 74 65 6e 73 69 6f 6e 73 | 2e 0a 5c 65 6e 64 7b 6e |tensions|..\end{n|
|000010f0| 6f 74 65 7d 0a 0a 5c 69 | 74 65 6d 20 5c 76 61 72 |ote}..\i|tem \var|
|00001100| 69 7b 6f 62 6a 7d 20 61 | 6e 64 20 5c 76 61 72 69 |i{obj} a|nd \vari|
|00001110| 69 7b 6f 62 6a 7d 20 61 | 72 65 20 62 6f 74 68 20 |i{obj} a|re both |
|00001120| 6e 75 6d 62 65 72 73 2c | 20 61 72 65 20 6e 75 6d |numbers,| are num|
|00001130| 65 72 69 63 61 6c 6c 79 | 0a 65 71 75 61 6c 20 28 |erically|.equal (|
|00001140| 73 65 65 20 5c 69 64 65 | 7b 3d 7d 5c 69 6e 64 65 |see \ide|{=}\inde|
|00001150| 78 7b 3d 7d 2c 20 73 65 | 63 74 69 6f 6e 7e 5c 72 |x{=}, se|ction~\r|
|00001160| 65 66 7b 6e 75 6d 62 65 | 72 73 65 63 74 69 6f 6e |ef{numbe|rsection|
|00001170| 7d 29 2c 20 61 6e 64 20 | 61 72 65 20 65 69 74 68 |}), and |are eith|
|00001180| 65 72 20 62 6f 74 68 0a | 65 78 61 63 74 5c 69 6e |er both.|exact\in|
|00001190| 64 65 78 7b 65 78 61 63 | 74 7d 20 6f 72 20 62 6f |dex{exac|t} or bo|
|000011a0| 74 68 20 69 6e 65 78 61 | 63 74 5c 69 6e 64 65 78 |th inexa|ct\index|
|000011b0| 7b 69 6e 65 78 61 63 74 | 7d 2e 0a 0a 5c 69 74 65 |{inexact|}...\ite|
|000011c0| 6d 20 5c 76 61 72 69 7b | 6f 62 6a 7d 20 61 6e 64 |m \vari{|obj} and|
|000011d0| 20 5c 76 61 72 69 69 7b | 6f 62 6a 7d 20 61 72 65 | \varii{|obj} are|
|000011e0| 20 62 6f 74 68 20 63 68 | 61 72 61 63 74 65 72 73 | both ch|aracters|
|000011f0| 20 61 6e 64 20 61 72 65 | 20 74 68 65 20 73 61 6d | and are| the sam|
|00001200| 65 0a 63 68 61 72 61 63 | 74 65 72 20 61 63 63 6f |e.charac|ter acco|
|00001210| 72 64 69 6e 67 20 74 6f | 20 74 68 65 20 5c 69 64 |rding to| the \id|
|00001220| 65 7b 63 68 61 72 3d 3f | 7d 20 70 72 6f 63 65 64 |e{char=?|} proced|
|00001230| 75 72 65 0a 28 73 65 63 | 74 69 6f 6e 7e 5c 72 65 |ure.(sec|tion~\re|
|00001240| 66 7b 63 68 61 72 61 63 | 74 65 72 73 65 63 74 69 |f{charac|tersecti|
|00001250| 6f 6e 7d 29 2e 0a 0a 5c | 69 74 65 6d 20 62 6f 74 |on})...\|item bot|
|00001260| 68 20 5c 76 61 72 69 7b | 6f 62 6a 7d 20 61 6e 64 |h \vari{|obj} and|
|00001270| 20 5c 76 61 72 69 69 7b | 6f 62 6a 7d 20 61 72 65 | \varii{|obj} are|
|00001280| 20 74 68 65 20 65 6d 70 | 74 79 20 6c 69 73 74 2e | the emp|ty list.|
|00001290| 0a 0a 5c 69 74 65 6d 20 | 5c 76 61 72 69 7b 6f 62 |..\item |\vari{ob|
|000012a0| 6a 7d 20 61 6e 64 20 5c | 76 61 72 69 69 7b 6f 62 |j} and \|varii{ob|
|000012b0| 6a 7d 20 61 72 65 20 70 | 61 69 72 73 2c 20 76 65 |j} are p|airs, ve|
|000012c0| 63 74 6f 72 73 2c 20 6f | 72 20 73 74 72 69 6e 67 |ctors, o|r string|
|000012d0| 73 20 74 68 61 74 20 64 | 65 6e 6f 74 65 20 74 68 |s that d|enote th|
|000012e0| 65 0a 73 61 6d 65 20 6c | 6f 63 61 74 69 6f 6e 73 |e.same l|ocations|
|000012f0| 20 69 6e 20 74 68 65 20 | 73 74 6f 72 65 20 28 73 | in the |store (s|
|00001300| 65 63 74 69 6f 6e 7e 5c | 72 65 66 7b 73 74 6f 72 |ection~\|ref{stor|
|00001310| 61 67 65 6d 6f 64 65 6c | 7d 29 2e 0a 0a 5c 69 74 |agemodel|})...\it|
|00001320| 65 6d 20 5c 76 61 72 69 | 7b 6f 62 6a 7d 20 61 6e |em \vari|{obj} an|
|00001330| 64 20 5c 76 61 72 69 69 | 7b 6f 62 6a 7d 20 61 72 |d \varii|{obj} ar|
|00001340| 65 20 70 72 6f 63 65 64 | 75 72 65 73 20 77 68 6f |e proced|ures who|
|00001350| 73 65 20 6c 6f 63 61 74 | 69 6f 6e 20 74 61 67 73 |se locat|ion tags|
|00001360| 20 61 72 65 0a 65 71 75 | 61 6c 20 28 73 65 63 74 | are.equ|al (sect|
|00001370| 69 6f 6e 7e 5c 72 65 66 | 7b 6c 61 6d 62 64 61 7d |ion~\ref|{lambda}|
|00001380| 29 2e 0a 5c 65 6e 64 7b | 69 74 65 6d 69 7a 65 7d |)..\end{|itemize}|
|00001390| 0a 0a 54 68 65 20 5c 69 | 64 65 7b 65 71 76 3f 7d |..The \i|de{eqv?}|
|000013a0| 20 70 72 6f 63 65 64 75 | 72 65 20 72 65 74 75 72 | procedu|re retur|
|000013b0| 6e 73 20 5c 73 63 68 66 | 61 6c 73 65 7b 7d 20 69 |ns \schf|alse{} i|
|000013c0| 66 3a 0a 0a 5c 62 65 67 | 69 6e 7b 69 74 65 6d 69 |f:..\beg|in{itemi|
|000013d0| 7a 65 7d 0a 5c 69 74 65 | 6d 20 5c 76 61 72 69 7b |ze}.\ite|m \vari{|
|000013e0| 6f 62 6a 7d 20 61 6e 64 | 20 5c 76 61 72 69 69 7b |obj} and| \varii{|
|000013f0| 6f 62 6a 7d 20 61 72 65 | 20 6f 66 20 64 69 66 66 |obj} are| of diff|
|00001400| 65 72 65 6e 74 20 74 79 | 70 65 73 0a 28 73 65 63 |erent ty|pes.(sec|
|00001410| 74 69 6f 6e 7e 5c 72 65 | 66 7b 64 69 73 6a 6f 69 |tion~\re|f{disjoi|
|00001420| 6e 74 6e 65 73 73 7d 29 | 2e 0a 0a 5c 69 74 65 6d |ntness})|...\item|
|00001430| 20 6f 6e 65 20 6f 66 20 | 5c 76 61 72 69 7b 6f 62 | one of |\vari{ob|
|00001440| 6a 7d 20 61 6e 64 20 5c | 76 61 72 69 69 7b 6f 62 |j} and \|varii{ob|
|00001450| 6a 7d 20 69 73 20 5c 73 | 63 68 74 72 75 65 7b 7d |j} is \s|chtrue{}|
|00001460| 20 62 75 74 20 74 68 65 | 20 6f 74 68 65 72 20 69 | but the| other i|
|00001470| 73 0a 5c 73 63 68 66 61 | 6c 73 65 7b 7d 2e 0a 0a |s.\schfa|lse{}...|
|00001480| 5c 69 74 65 6d 20 5c 76 | 61 72 69 7b 6f 62 6a 7d |\item \v|ari{obj}|
|00001490| 20 61 6e 64 20 5c 76 61 | 72 69 69 7b 6f 62 6a 7d | and \va|rii{obj}|
|000014a0| 20 61 72 65 20 73 79 6d | 62 6f 6c 73 20 62 75 74 | are sym|bols but|
|000014b0| 0a 0a 5c 62 65 67 69 6e | 7b 73 63 68 65 6d 65 7d |..\begin|{scheme}|
|000014c0| 0a 28 73 74 72 69 6e 67 | 3d 3f 20 28 73 79 6d 62 |.(string|=? (symb|
|000014d0| 6f 6c 2d 3e 73 74 72 69 | 6e 67 20 5c 76 61 72 69 |ol->stri|ng \vari|
|000014e0| 7b 6f 62 6a 7d 29 0a 20 | 20 20 20 20 20 20 20 20 |{obj}). | |
|000014f0| 20 28 73 79 6d 62 6f 6c | 2d 3e 73 74 72 69 6e 67 | (symbol|->string|
|00001500| 20 5c 76 61 72 69 69 7b | 6f 62 6a 7d 29 29 0a 20 | \varii{|obj})). |
|00001510| 20 20 20 5c 65 76 20 20 | 5c 73 63 68 66 61 6c 73 | \ev |\schfals|
|00001520| 65 25 0a 5c 65 6e 64 7b | 73 63 68 65 6d 65 7d 0a |e%.\end{|scheme}.|
|00001530| 0a 5c 69 74 65 6d 20 6f | 6e 65 20 6f 66 20 5c 76 |.\item o|ne of \v|
|00001540| 61 72 69 7b 6f 62 6a 7d | 20 61 6e 64 20 5c 76 61 |ari{obj}| and \va|
|00001550| 72 69 69 7b 6f 62 6a 7d | 20 69 73 20 61 6e 20 65 |rii{obj}| is an e|
|00001560| 78 61 63 74 20 6e 75 6d | 62 65 72 20 62 75 74 20 |xact num|ber but |
|00001570| 74 68 65 20 6f 74 68 65 | 72 0a 69 73 20 61 6e 20 |the othe|r.is an |
|00001580| 69 6e 65 78 61 63 74 20 | 6e 75 6d 62 65 72 2e 0a |inexact |number..|
|00001590| 0a 5c 69 74 65 6d 20 5c | 76 61 72 69 7b 6f 62 6a |.\item \|vari{obj|
|000015a0| 7d 20 61 6e 64 20 5c 76 | 61 72 69 69 7b 6f 62 6a |} and \v|arii{obj|
|000015b0| 7d 20 61 72 65 20 6e 75 | 6d 62 65 72 73 20 66 6f |} are nu|mbers fo|
|000015c0| 72 20 77 68 69 63 68 20 | 74 68 65 20 5c 69 64 65 |r which |the \ide|
|000015d0| 7b 3d 7d 0a 70 72 6f 63 | 65 64 75 72 65 20 72 65 |{=}.proc|edure re|
|000015e0| 74 75 72 6e 73 20 5c 73 | 63 68 66 61 6c 73 65 7b |turns \s|chfalse{|
|000015f0| 7d 2e 0a 0a 5c 69 74 65 | 6d 20 5c 76 61 72 69 7b |}...\ite|m \vari{|
|00001600| 6f 62 6a 7d 20 61 6e 64 | 20 5c 76 61 72 69 69 7b |obj} and| \varii{|
|00001610| 6f 62 6a 7d 20 61 72 65 | 20 63 68 61 72 61 63 74 |obj} are| charact|
|00001620| 65 72 73 20 66 6f 72 20 | 77 68 69 63 68 20 74 68 |ers for |which th|
|00001630| 65 20 5c 69 64 65 7b 63 | 68 61 72 3d 3f 7d 0a 70 |e \ide{c|har=?}.p|
|00001640| 72 6f 63 65 64 75 72 65 | 20 72 65 74 75 72 6e 73 |rocedure| returns|
|00001650| 20 5c 73 63 68 66 61 6c | 73 65 7b 7d 2e 0a 0a 5c | \schfal|se{}...\|
|00001660| 69 74 65 6d 20 6f 6e 65 | 20 6f 66 20 5c 76 61 72 |item one| of \var|
|00001670| 69 7b 6f 62 6a 7d 20 61 | 6e 64 20 5c 76 61 72 69 |i{obj} a|nd \vari|
|00001680| 69 7b 6f 62 6a 7d 20 69 | 73 20 74 68 65 20 65 6d |i{obj} i|s the em|
|00001690| 70 74 79 20 6c 69 73 74 | 20 62 75 74 20 74 68 65 |pty list| but the|
|000016a0| 20 6f 74 68 65 72 0a 69 | 73 20 6e 6f 74 2e 0a 0a | other.i|s not...|
|000016b0| 5c 69 74 65 6d 20 5c 76 | 61 72 69 7b 6f 62 6a 7d |\item \v|ari{obj}|
|000016c0| 20 61 6e 64 20 5c 76 61 | 72 69 69 7b 6f 62 6a 7d | and \va|rii{obj}|
|000016d0| 20 61 72 65 20 70 61 69 | 72 73 2c 20 76 65 63 74 | are pai|rs, vect|
|000016e0| 6f 72 73 2c 20 6f 72 20 | 73 74 72 69 6e 67 73 20 |ors, or |strings |
|000016f0| 74 68 61 74 20 64 65 6e | 6f 74 65 0a 64 69 73 74 |that den|ote.dist|
|00001700| 69 6e 63 74 20 6c 6f 63 | 61 74 69 6f 6e 73 2e 0a |inct loc|ations..|
|00001710| 0a 5c 69 74 65 6d 20 5c | 76 61 72 69 7b 6f 62 6a |.\item \|vari{obj|
|00001720| 7d 20 61 6e 64 20 5c 76 | 61 72 69 69 7b 6f 62 6a |} and \v|arii{obj|
|00001730| 7d 20 61 72 65 20 70 72 | 6f 63 65 64 75 72 65 73 |} are pr|ocedures|
|00001740| 20 74 68 61 74 20 77 6f | 75 6c 64 20 62 65 68 61 | that wo|uld beha|
|00001750| 76 65 20 64 69 66 66 65 | 72 65 6e 74 6c 79 0a 28 |ve diffe|rently.(|
|00001760| 72 65 74 75 72 6e 20 61 | 20 64 69 66 66 65 72 65 |return a| differe|
|00001770| 6e 74 20 76 61 6c 75 65 | 20 6f 72 20 68 61 76 65 |nt value| or have|
|00001780| 20 64 69 66 66 65 72 65 | 6e 74 20 73 69 64 65 20 | differe|nt side |
|00001790| 65 66 66 65 63 74 73 29 | 20 66 6f 72 20 73 6f 6d |effects)| for som|
|000017a0| 65 20 61 72 67 75 6d 65 | 6e 74 73 2e 0a 0a 5c 65 |e argume|nts...\e|
|000017b0| 6e 64 7b 69 74 65 6d 69 | 7a 65 7d 0a 0a 5c 62 65 |nd{itemi|ze}..\be|
|000017c0| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 65 71 76 |gin{sche|me}.(eqv|
|000017d0| 3f 20 27 61 20 27 61 29 | 20 20 20 20 20 20 20 20 |? 'a 'a)| |
|000017e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|000017f0| 20 20 5c 73 63 68 74 72 | 75 65 0a 28 65 71 76 3f | \schtr|ue.(eqv?|
|00001800| 20 27 61 20 27 62 29 20 | 20 20 20 20 20 20 20 20 | 'a 'b) | |
|00001810| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00001820| 20 5c 73 63 68 66 61 6c | 73 65 0a 28 65 71 76 3f | \schfal|se.(eqv?|
|00001830| 20 32 20 32 29 20 20 20 | 20 20 20 20 20 20 20 20 | 2 2) | |
|00001840| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00001850| 20 5c 73 63 68 74 72 75 | 65 0a 28 65 71 76 3f 20 | \schtru|e.(eqv? |
|00001860| 27 28 29 20 27 28 29 29 | 20 20 20 20 20 20 20 20 |'() '())| |
|00001870| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 | | \ev |
|00001880| 5c 73 63 68 74 72 75 65 | 0a 28 65 71 76 3f 20 31 |\schtrue|.(eqv? 1|
|00001890| 30 30 30 30 30 30 30 30 | 20 31 30 30 30 30 30 30 |00000000| 1000000|
|000018a0| 30 30 29 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c |00) | \ev \|
|000018b0| 73 63 68 74 72 75 65 0a | 28 65 71 76 3f 20 28 63 |schtrue.|(eqv? (c|
|000018c0| 6f 6e 73 20 31 20 32 29 | 20 28 63 6f 6e 73 20 31 |ons 1 2)| (cons 1|
|000018d0| 20 32 29 29 20 20 20 20 | 20 5c 65 76 20 20 5c 73 | 2)) | \ev \s|
|000018e0| 63 68 66 61 6c 73 65 0a | 28 65 71 76 3f 20 28 6c |chfalse.|(eqv? (l|
|000018f0| 61 6d 62 64 61 20 28 29 | 20 31 29 0a 20 20 20 20 |ambda ()| 1). |
|00001900| 20 20 28 6c 61 6d 62 64 | 61 20 28 29 20 32 29 29 | (lambd|a () 2))|
|00001910| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00001920| 20 20 5c 73 63 68 66 61 | 6c 73 65 0a 28 65 71 76 | \schfa|lse.(eqv|
|00001930| 3f 20 5c 23 66 20 27 6e | 69 6c 29 20 20 20 20 20 |? \#f 'n|il) |
|00001940| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00001950| 20 20 5c 73 63 68 66 61 | 6c 73 65 0a 28 6c 65 74 | \schfa|lse.(let|
|00001960| 20 28 28 70 20 28 6c 61 | 6d 62 64 61 20 28 78 29 | ((p (la|mbda (x)|
|00001970| 20 78 29 29 29 0a 20 20 | 28 65 71 76 3f 20 70 20 | x))). |(eqv? p |
|00001980| 70 29 29 09 09 20 20 20 | 20 20 20 20 20 20 5c 65 |p)).. | \e|
|00001990| 76 20 20 5c 73 63 68 74 | 72 75 65 25 0a 5c 65 6e |v \scht|rue%.\en|
|000019a0| 64 7b 73 63 68 65 6d 65 | 7d 0a 0a 54 68 65 20 66 |d{scheme|}..The f|
|000019b0| 6f 6c 6c 6f 77 69 6e 67 | 20 65 78 61 6d 70 6c 65 |ollowing| example|
|000019c0| 73 20 69 6c 6c 75 73 74 | 72 61 74 65 20 63 61 73 |s illust|rate cas|
|000019d0| 65 73 20 69 6e 20 77 68 | 69 63 68 20 74 68 65 20 |es in wh|ich the |
|000019e0| 61 62 6f 76 65 20 72 75 | 6c 65 73 20 64 6f 0a 6e |above ru|les do.n|
|000019f0| 6f 74 20 66 75 6c 6c 79 | 20 73 70 65 63 69 66 79 |ot fully| specify|
|00001a00| 20 74 68 65 20 62 65 68 | 61 76 69 6f 72 20 6f 66 | the beh|avior of|
|00001a10| 20 5c 69 64 65 7b 65 71 | 76 3f 7d 2e 20 20 41 6c | \ide{eq|v?}. Al|
|00001a20| 6c 20 74 68 61 74 20 63 | 61 6e 20 62 65 20 73 61 |l that c|an be sa|
|00001a30| 69 64 0a 61 62 6f 75 74 | 20 73 75 63 68 20 63 61 |id.about| such ca|
|00001a40| 73 65 73 20 69 73 20 74 | 68 61 74 20 74 68 65 20 |ses is t|hat the |
|00001a50| 76 61 6c 75 65 20 72 65 | 74 75 72 6e 65 64 20 62 |value re|turned b|
|00001a60| 79 20 5c 69 64 65 7b 65 | 71 76 3f 7d 20 6d 75 73 |y \ide{e|qv?} mus|
|00001a70| 74 20 62 65 20 61 0a 62 | 6f 6f 6c 65 61 6e 2e 0a |t be a.b|oolean..|
|00001a80| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00001a90| 28 65 71 76 3f 20 22 22 | 20 22 22 29 20 20 20 20 |(eqv? ""| "") |
|00001aa0| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 75 | | \ev \u|
|00001ab0| 6e 73 70 65 63 69 66 69 | 65 64 0a 28 65 71 76 3f |nspecifi|ed.(eqv?|
|00001ac0| 20 27 5c 23 28 29 20 27 | 5c 23 28 29 29 20 20 20 | '\#() '|\#()) |
|00001ad0| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 75 6e 73 70 | \e|v \unsp|
|00001ae0| 65 63 69 66 69 65 64 0a | 28 65 71 76 3f 20 28 6c |ecified.|(eqv? (l|
|00001af0| 61 6d 62 64 61 20 28 78 | 29 20 78 29 0a 20 20 20 |ambda (x|) x). |
|00001b00| 20 20 20 28 6c 61 6d 62 | 64 61 20 28 78 29 20 78 | (lamb|da (x) x|
|00001b10| 29 29 20 20 20 20 5c 65 | 76 20 20 5c 75 6e 73 70 |)) \e|v \unsp|
|00001b20| 65 63 69 66 69 65 64 0a | 28 65 71 76 3f 20 28 6c |ecified.|(eqv? (l|
|00001b30| 61 6d 62 64 61 20 28 78 | 29 20 78 29 0a 20 20 20 |ambda (x|) x). |
|00001b40| 20 20 20 28 6c 61 6d 62 | 64 61 20 28 79 29 20 79 | (lamb|da (y) y|
|00001b50| 29 29 20 20 20 20 5c 65 | 76 20 20 5c 75 6e 73 70 |)) \e|v \unsp|
|00001b60| 65 63 69 66 69 65 64 25 | 0a 5c 65 6e 64 7b 73 63 |ecified%|.\end{sc|
|00001b70| 68 65 6d 65 7d 0a 0a 54 | 68 65 20 6e 65 78 74 20 |heme}..T|he next |
|00001b80| 73 65 74 20 6f 66 20 65 | 78 61 6d 70 6c 65 73 20 |set of e|xamples |
|00001b90| 73 68 6f 77 73 20 74 68 | 65 20 75 73 65 20 6f 66 |shows th|e use of|
|00001ba0| 20 5c 69 64 65 7b 65 71 | 76 3f 7d 5c 20 77 69 74 | \ide{eq|v?}\ wit|
|00001bb0| 68 20 70 72 6f 63 65 64 | 75 72 65 73 0a 74 68 61 |h proced|ures.tha|
|00001bc0| 74 20 68 61 76 65 20 6c | 6f 63 61 6c 20 73 74 61 |t have l|ocal sta|
|00001bd0| 74 65 2e 20 20 5c 69 64 | 65 7b 47 65 6e 2d 63 6f |te. \id|e{Gen-co|
|00001be0| 75 6e 74 65 72 7d 20 6d | 75 73 74 20 72 65 74 75 |unter} m|ust retu|
|00001bf0| 72 6e 20 61 20 64 69 73 | 74 69 6e 63 74 0a 70 72 |rn a dis|tinct.pr|
|00001c00| 6f 63 65 64 75 72 65 20 | 65 76 65 72 79 20 74 69 |ocedure |every ti|
|00001c10| 6d 65 2c 20 73 69 6e 63 | 65 20 65 61 63 68 20 70 |me, sinc|e each p|
|00001c20| 72 6f 63 65 64 75 72 65 | 20 68 61 73 20 69 74 73 |rocedure| has its|
|00001c30| 20 6f 77 6e 20 69 6e 74 | 65 72 6e 61 6c 20 63 6f | own int|ernal co|
|00001c40| 75 6e 74 65 72 2e 0a 5c | 69 64 65 7b 47 65 6e 2d |unter..\|ide{Gen-|
|00001c50| 6c 6f 73 65 72 7d 2c 20 | 68 6f 77 65 76 65 72 2c |loser}, |however,|
|00001c60| 20 72 65 74 75 72 6e 73 | 20 65 71 75 69 76 61 6c | returns| equival|
|00001c70| 65 6e 74 20 70 72 6f 63 | 65 64 75 72 65 73 20 65 |ent proc|edures e|
|00001c80| 61 63 68 20 74 69 6d 65 | 2c 20 73 69 6e 63 65 0a |ach time|, since.|
|00001c90| 74 68 65 20 6c 6f 63 61 | 6c 20 73 74 61 74 65 20 |the loca|l state |
|00001ca0| 64 6f 65 73 20 6e 6f 74 | 20 61 66 66 65 63 74 20 |does not| affect |
|00001cb0| 74 68 65 20 76 61 6c 75 | 65 20 6f 72 20 73 69 64 |the valu|e or sid|
|00001cc0| 65 20 65 66 66 65 63 74 | 73 20 6f 66 20 74 68 65 |e effect|s of the|
|00001cd0| 0a 70 72 6f 63 65 64 75 | 72 65 73 2e 0a 0a 5c 62 |.procedu|res...\b|
|00001ce0| 65 67 69 6e 7b 73 63 68 | 65 6d 65 7d 0a 28 64 65 |egin{sch|eme}.(de|
|00001cf0| 66 69 6e 65 20 67 65 6e | 2d 63 6f 75 6e 74 65 72 |fine gen|-counter|
|00001d00| 0a 20 20 28 6c 61 6d 62 | 64 61 20 28 29 0a 20 20 |. (lamb|da (). |
|00001d10| 20 20 28 6c 65 74 20 28 | 28 6e 20 30 29 29 0a 20 | (let (|(n 0)). |
|00001d20| 20 20 20 20 20 28 6c 61 | 6d 62 64 61 20 28 29 20 | (la|mbda () |
|00001d30| 28 73 65 74 21 20 6e 20 | 28 2b 20 6e 20 31 29 29 |(set! n |(+ n 1))|
|00001d40| 20 6e 29 29 29 29 0a 28 | 6c 65 74 20 28 28 67 20 | n)))).(|let ((g |
|00001d50| 28 67 65 6e 2d 63 6f 75 | 6e 74 65 72 29 29 29 0a |(gen-cou|nter))).|
|00001d60| 20 20 28 65 71 76 3f 20 | 67 20 67 29 29 20 20 20 | (eqv? |g g)) |
|00001d70| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 73 63 | |\ev \sc|
|00001d80| 68 74 72 75 65 0a 28 65 | 71 76 3f 20 28 67 65 6e |htrue.(e|qv? (gen|
|00001d90| 2d 63 6f 75 6e 74 65 72 | 29 20 28 67 65 6e 2d 63 |-counter|) (gen-c|
|00001da0| 6f 75 6e 74 65 72 29 29 | 0a 20 20 20 20 20 20 20 |ounter))|. |
|00001db0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001dc0| 20 5c 65 76 20 20 5c 73 | 63 68 66 61 6c 73 65 0a | \ev \s|chfalse.|
|00001dd0| 28 64 65 66 69 6e 65 20 | 67 65 6e 2d 6c 6f 73 65 |(define |gen-lose|
|00001de0| 72 0a 20 20 28 6c 61 6d | 62 64 61 20 28 29 0a 20 |r. (lam|bda (). |
|00001df0| 20 20 20 28 6c 65 74 20 | 28 28 6e 20 30 29 29 0a | (let |((n 0)).|
|00001e00| 20 20 20 20 20 20 28 6c | 61 6d 62 64 61 20 28 29 | (l|ambda ()|
|00001e10| 20 28 73 65 74 21 20 6e | 20 28 2b 20 6e 20 31 29 | (set! n| (+ n 1)|
|00001e20| 29 20 32 37 29 29 29 29 | 0a 28 6c 65 74 20 28 28 |) 27))))|.(let ((|
|00001e30| 67 20 28 67 65 6e 2d 6c | 6f 73 65 72 29 29 29 0a |g (gen-l|oser))).|
|00001e40| 20 20 28 65 71 76 3f 20 | 67 20 67 29 29 20 20 20 | (eqv? |g g)) |
|00001e50| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 73 63 | |\ev \sc|
|00001e60| 68 74 72 75 65 0a 28 65 | 71 76 3f 20 28 67 65 6e |htrue.(e|qv? (gen|
|00001e70| 2d 6c 6f 73 65 72 29 20 | 28 67 65 6e 2d 6c 6f 73 |-loser) |(gen-los|
|00001e80| 65 72 29 29 0a 20 20 20 | 20 20 20 20 20 20 20 20 |er)). | |
|00001e90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00001ea0| 20 20 5c 75 6e 73 70 65 | 63 69 66 69 65 64 0a 0a | \unspe|cified..|
|00001eb0| 28 6c 65 74 72 65 63 20 | 28 28 66 20 28 6c 61 6d |(letrec |((f (lam|
|00001ec0| 62 64 61 20 28 29 20 28 | 69 66 20 28 65 71 76 3f |bda () (|if (eqv?|
|00001ed0| 20 66 20 67 29 20 27 62 | 6f 74 68 20 27 66 29 29 | f g) 'b|oth 'f))|
|00001ee0| 29 0a 20 20 20 20 20 20 | 20 20 20 28 67 20 28 6c |). | (g (l|
|00001ef0| 61 6d 62 64 61 20 28 29 | 20 28 69 66 20 28 65 71 |ambda ()| (if (eq|
|00001f00| 76 3f 20 66 20 67 29 20 | 27 62 6f 74 68 20 27 67 |v? f g) |'both 'g|
|00001f10| 29 29 29 0a 20 20 28 65 | 71 76 3f 20 66 20 67 29 |))). (e|qv? f g)|
|00001f20| 29 0a 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |). | |
|00001f30| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c | | \ev \|
|00001f40| 75 6e 73 70 65 63 69 66 | 69 65 64 0a 0a 28 6c 65 |unspecif|ied..(le|
|00001f50| 74 72 65 63 20 28 28 66 | 20 28 6c 61 6d 62 64 61 |trec ((f| (lambda|
|00001f60| 20 28 29 20 28 69 66 20 | 28 65 71 76 3f 20 66 20 | () (if |(eqv? f |
|00001f70| 67 29 20 27 66 20 27 62 | 6f 74 68 29 29 29 0a 20 |g) 'f 'b|oth))). |
|00001f80| 20 20 20 20 20 20 20 20 | 28 67 20 28 6c 61 6d 62 | |(g (lamb|
|00001f90| 64 61 20 28 29 20 28 69 | 66 20 28 65 71 76 3f 20 |da () (i|f (eqv? |
|00001fa0| 66 20 67 29 20 27 67 20 | 27 62 6f 74 68 29 29 29 |f g) 'g |'both)))|
|00001fb0| 0a 20 20 28 65 71 76 3f | 20 66 20 67 29 29 0a 20 |. (eqv?| f g)). |
|00001fc0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001fd0| 20 20 20 20 20 20 20 5c | 65 76 20 20 5c 73 63 68 | \|ev \sch|
|00001fe0| 66 61 6c 73 65 25 0a 5c | 65 6e 64 7b 73 63 68 65 |false%.\|end{sche|
|00001ff0| 6d 65 7d 0a 0a 4f 62 6a | 65 63 74 73 20 6f 69 63 |me}..Obj|ects oic|
|00002000| 64 69 73 74 69 6e 63 74 | 20 74 79 70 65 73 20 6d |distinct| types m|
|00002010| 75 73 74 20 6e 65 76 65 | 72 20 62 65 20 72 65 67 |ust neve|r be reg|
|00002020| 61 72 64 65 64 20 61 73 | 20 74 68 65 20 73 61 6d |arded as| the sam|
|00002030| 65 20 6f 62 6a 65 63 74 | 2c 0a 65 78 63 65 70 74 |e object|,.except|
|00002040| 20 74 68 61 74 20 5c 73 | 63 68 66 61 6c 73 65 7b | that \s|chfalse{|
|00002050| 7d 20 61 6e 64 20 74 68 | 65 20 65 6d 70 74 79 20 |} and th|e empty |
|00002060| 6c 69 73 74 5c 69 6e 64 | 65 78 7b 65 6d 70 74 79 |list\ind|ex{empty|
|00002070| 20 6c 69 73 74 7d 20 61 | 72 65 20 70 65 72 6d 69 | list} a|re permi|
|00002080| 74 74 65 64 20 74 6f 20 | 62 65 0a 69 64 65 6e 74 |tted to |be.ident|
|00002090| 69 63 61 6c 2e 0a 0a 5c | 62 65 67 69 6e 7b 73 63 |ical...\|begin{sc|
|000020a0| 68 65 6d 65 7d 0a 28 65 | 71 76 3f 20 27 28 29 20 |heme}.(e|qv? '() |
|000020b0| 5c 73 63 68 66 61 6c 73 | 65 29 20 20 20 20 5c 65 |\schfals|e) \e|
|000020c0| 76 20 20 5c 75 6e 73 70 | 65 63 69 66 69 65 64 25 |v \unsp|ecified%|
|000020d0| 0a 5c 65 6e 64 7b 73 63 | 68 65 6d 65 7d 0a 0a 53 |.\end{sc|heme}..S|
|000020e0| 69 6e 63 65 20 69 74 20 | 69 73 20 61 6e 20 65 72 |ince it |is an er|
|000020f0| 72 6f 72 20 74 6f 20 6d | 6f 64 69 66 79 20 63 6f |ror to m|odify co|
|00002100| 6e 73 74 61 6e 74 20 6f | 62 6a 65 63 74 73 20 28 |nstant o|bjects (|
|00002110| 74 68 6f 73 65 20 72 65 | 74 75 72 6e 65 64 20 62 |those re|turned b|
|00002120| 79 0a 6c 69 74 65 72 61 | 6c 20 65 78 70 72 65 73 |y.litera|l expres|
|00002130| 73 69 6f 6e 73 29 2c 20 | 69 6d 70 6c 65 6d 65 6e |sions), |implemen|
|00002140| 74 61 74 69 6f 6e 73 20 | 61 72 65 20 70 65 72 6d |tations |are perm|
|00002150| 69 74 74 65 64 2c 20 74 | 68 6f 75 67 68 20 6e 6f |itted, t|hough no|
|00002160| 74 0a 72 65 71 75 69 72 | 65 64 2c 20 74 6f 20 73 |t.requir|ed, to s|
|00002170| 68 61 72 65 20 73 74 72 | 75 63 74 75 72 65 20 62 |hare str|ucture b|
|00002180| 65 74 77 65 65 6e 20 63 | 6f 6e 73 74 61 6e 74 73 |etween c|onstants|
|00002190| 20 77 68 65 72 65 20 61 | 70 70 72 6f 70 72 69 61 | where a|ppropria|
|000021a0| 74 65 2e 20 20 54 68 75 | 73 0a 74 68 65 20 76 61 |te. Thu|s.the va|
|000021b0| 6c 75 65 20 6f 66 20 5c | 69 64 65 7b 65 71 76 3f |lue of \|ide{eqv?|
|000021c0| 7d 20 6f 6e 20 63 6f 6e | 73 74 61 6e 74 73 20 69 |} on con|stants i|
|000021d0| 73 20 73 6f 6d 65 74 69 | 6d 65 73 0a 69 6d 70 6c |s someti|mes.impl|
|000021e0| 65 6d 65 6e 74 61 74 69 | 6f 6e 2d 64 65 70 65 6e |ementati|on-depen|
|000021f0| 64 65 6e 74 2e 0a 0a 5c | 62 65 67 69 6e 7b 73 63 |dent...\|begin{sc|
|00002200| 68 65 6d 65 7d 0a 28 6c | 65 74 20 28 28 78 20 27 |heme}.(l|et ((x '|
|00002210| 28 61 29 29 29 0a 20 20 | 28 65 71 76 3f 20 78 20 |(a))). |(eqv? x |
|00002220| 78 29 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |x)) | |
|00002230| 20 20 20 20 20 20 20 5c | 65 76 20 20 5c 73 63 68 | \|ev \sch|
|00002240| 74 72 75 65 0a 28 65 71 | 76 3f 20 27 28 61 29 20 |true.(eq|v? '(a) |
|00002250| 27 28 61 29 29 20 20 20 | 20 20 20 20 20 20 20 20 |'(a)) | |
|00002260| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 75 6e 73 70 | \e|v \unsp|
|00002270| 65 63 69 66 69 65 64 0a | 28 65 71 76 3f 20 22 61 |ecified.|(eqv? "a|
|00002280| 22 20 22 61 22 29 20 20 | 20 20 20 20 20 20 20 20 |" "a") | |
|00002290| 20 20 20 20 20 20 20 20 | 20 5c 65 76 20 20 5c 75 | | \ev \u|
|000022a0| 6e 73 70 65 63 69 66 69 | 65 64 0a 28 65 71 76 3f |nspecifi|ed.(eqv?|
|000022b0| 20 27 28 62 29 20 28 63 | 64 72 20 27 28 61 20 62 | '(b) (c|dr '(a b|
|000022c0| 29 29 29 09 20 5c 65 76 | 20 20 5c 75 6e 73 70 65 |))). \ev| \unspe|
|000022d0| 63 69 66 69 65 64 25 0a | 5c 65 6e 64 7b 73 63 68 |cified%.|\end{sch|
|000022e0| 65 6d 65 7d 0a 0a 5c 62 | 65 67 69 6e 7b 6e 6f 74 |eme}..\b|egin{not|
|000022f0| 65 7d 20 0a 54 68 65 20 | 61 62 6f 76 65 20 64 65 |e} .The |above de|
|00002300| 66 69 6e 69 74 69 6f 6e | 20 6f 66 20 5c 69 64 65 |finition| of \ide|
|00002310| 7b 65 71 76 3f 7d 20 61 | 6c 6c 6f 77 73 20 69 6d |{eqv?} a|llows im|
|00002320| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 73 20 6c 61 |plementa|tions la|
|00002330| 74 69 74 75 64 65 20 69 | 6e 0a 74 68 65 69 72 20 |titude i|n.their |
|00002340| 74 72 65 61 74 6d 65 6e | 74 20 6f 66 20 70 72 6f |treatmen|t of pro|
|00002350| 63 65 64 75 72 65 73 20 | 61 6e 64 20 6c 69 74 65 |cedures |and lite|
|00002360| 72 61 6c 73 3a 20 20 69 | 6d 70 6c 65 6d 65 6e 74 |rals: i|mplement|
|00002370| 61 74 69 6f 6e 73 20 61 | 72 65 20 66 72 65 65 0a |ations a|re free.|
|00002380| 65 69 74 68 65 72 20 74 | 6f 20 64 65 74 65 63 74 |either t|o detect|
|00002390| 20 6f 72 20 74 6f 20 66 | 61 69 6c 20 74 6f 20 64 | or to f|ail to d|
|000023a0| 65 74 65 63 74 20 74 68 | 61 74 20 74 77 6f 20 70 |etect th|at two p|
|000023b0| 72 6f 63 65 64 75 72 65 | 73 20 6f 72 20 74 77 6f |rocedure|s or two|
|000023c0| 20 6c 69 74 65 72 61 6c | 73 0a 61 72 65 20 65 71 | literal|s.are eq|
|000023d0| 75 69 76 61 6c 65 6e 74 | 20 74 6f 20 65 61 63 68 |uivalent| to each|
|000023e0| 20 6f 74 68 65 72 2c 20 | 61 6e 64 20 63 61 6e 20 | other, |and can |
|000023f0| 64 65 63 69 64 65 20 77 | 68 65 74 68 65 72 20 6f |decide w|hether o|
|00002400| 72 20 6e 6f 74 20 74 6f | 0a 6d 65 72 67 65 20 72 |r not to|.merge r|
|00002410| 65 70 72 65 73 65 6e 74 | 61 74 69 6f 6e 73 20 6f |epresent|ations o|
|00002420| 66 20 65 71 75 69 76 61 | 6c 65 6e 74 20 6f 62 6a |f equiva|lent obj|
|00002430| 65 63 74 73 20 62 79 20 | 75 73 69 6e 67 20 74 68 |ects by |using th|
|00002440| 65 20 73 61 6d 65 20 70 | 6f 69 6e 74 65 72 20 6f |e same p|ointer o|
|00002450| 72 0a 62 69 74 20 70 61 | 74 74 65 72 6e 20 74 6f |r.bit pa|ttern to|
|00002460| 20 72 65 70 72 65 73 65 | 6e 74 20 62 6f 74 68 2e | represe|nt both.|
|00002470| 0a 5c 65 6e 64 7b 6e 6f | 74 65 7d 0a 0a 5c 65 6e |.\end{no|te}..\en|
|00002480| 64 7b 65 6e 74 72 79 7d | 0a 0a 0a 5c 62 65 67 69 |d{entry}|...\begi|
|00002490| 6e 7b 65 6e 74 72 79 7d | 7b 25 0a 5c 70 72 6f 74 |n{entry}|{%.\prot|
|000024a0| 6f 7b 65 71 3f 7d 7b 20 | 5c 76 61 72 69 7b 6f 62 |o{eq?}{ |\vari{ob|
|000024b0| 6a 7d 20 5c 76 61 72 69 | 69 7b 6f 62 6a 7d 7d 7b |j} \vari|i{obj}}{|
|000024c0| 65 73 73 65 6e 74 69 61 | 6c 20 70 72 6f 63 65 64 |essentia|l proced|
|000024d0| 75 72 65 7d 7d 0a 0a 5c | 69 64 65 7b 45 71 3f 7d |ure}}..\|ide{Eq?}|
|000024e0| 5c 20 69 73 20 73 69 6d | 69 6c 61 72 20 74 6f 20 |\ is sim|ilar to |
|000024f0| 5c 69 64 65 7b 65 71 76 | 3f 7d 5c 20 65 78 63 65 |\ide{eqv|?}\ exce|
|00002500| 70 74 20 74 68 61 74 20 | 69 6e 20 73 6f 6d 65 20 |pt that |in some |
|00002510| 63 61 73 65 73 20 69 74 | 20 69 73 0a 63 61 70 61 |cases it| is.capa|
|00002520| 62 6c 65 20 6f 66 20 64 | 69 73 63 65 72 6e 69 6e |ble of d|iscernin|
|00002530| 67 20 64 69 73 74 69 6e | 63 74 69 6f 6e 73 20 66 |g distin|ctions f|
|00002540| 69 6e 65 72 20 74 68 61 | 6e 20 74 68 6f 73 65 20 |iner tha|n those |
|00002550| 64 65 74 65 63 74 61 62 | 6c 65 20 62 79 0a 5c 69 |detectab|le by.\i|
|00002560| 64 65 7b 65 71 76 3f 7d | 2e 0a 0a 5c 76 65 73 74 |de{eqv?}|...\vest|
|00002570| 20 5c 69 64 65 7b 45 71 | 3f 7d 5c 20 61 6e 64 20 | \ide{Eq|?}\ and |
|00002580| 5c 69 64 65 7b 65 71 76 | 3f 7d 5c 20 61 72 65 20 |\ide{eqv|?}\ are |
|00002590| 67 75 61 72 61 6e 74 65 | 65 64 20 74 6f 20 68 61 |guarante|ed to ha|
|000025a0| 76 65 20 74 68 65 20 73 | 61 6d 65 0a 62 65 68 61 |ve the s|ame.beha|
|000025b0| 76 69 6f 72 20 6f 6e 20 | 73 79 6d 62 6f 6c 73 2c |vior on |symbols,|
|000025c0| 20 62 6f 6f 6c 65 61 6e | 73 2c 20 74 68 65 20 65 | boolean|s, the e|
|000025d0| 6d 70 74 79 20 6c 69 73 | 74 2c 20 70 61 69 72 73 |mpty lis|t, pairs|
|000025e0| 2c 20 61 6e 64 20 6e 6f | 6e 2d 65 6d 70 74 79 0a |, and no|n-empty.|
|000025f0| 73 74 72 69 6e 67 73 20 | 61 6e 64 20 76 65 63 74 |strings |and vect|
|00002600| 6f 72 73 2e 20 20 5c 69 | 64 65 7b 45 71 3f 7d 27 |ors. \i|de{Eq?}'|
|00002610| 73 20 62 65 68 61 76 69 | 6f 72 20 6f 6e 20 6e 75 |s behavi|or on nu|
|00002620| 6d 62 65 72 73 20 61 6e | 64 20 63 68 61 72 61 63 |mbers an|d charac|
|00002630| 74 65 72 73 20 69 73 0a | 69 6d 70 6c 65 6d 65 6e |ters is.|implemen|
|00002640| 74 61 74 69 6f 6e 2d 64 | 65 70 65 6e 64 65 6e 74 |tation-d|ependent|
|00002650| 2c 20 62 75 74 20 69 74 | 20 77 69 6c 6c 20 61 6c |, but it| will al|
|00002660| 77 61 79 73 20 72 65 74 | 75 72 6e 20 65 69 74 68 |ways ret|urn eith|
|00002670| 65 72 20 74 72 75 65 20 | 6f 72 0a 66 61 6c 73 65 |er true |or.false|
|00002680| 2c 20 61 6e 64 20 77 69 | 6c 6c 20 72 65 74 75 72 |, and wi|ll retur|
|00002690| 6e 20 74 72 75 65 20 6f | 6e 6c 79 20 77 68 65 6e |n true o|nly when|
|000026a0| 20 5c 69 64 65 7b 65 71 | 76 3f 7d 5c 20 77 6f 75 | \ide{eq|v?}\ wou|
|000026b0| 6c 64 20 61 6c 73 6f 20 | 72 65 74 75 72 6e 0a 74 |ld also |return.t|
|000026c0| 72 75 65 2e 20 20 5c 69 | 64 65 7b 45 71 3f 7d 20 |rue. \i|de{Eq?} |
|000026d0| 6d 61 79 20 61 6c 73 6f | 20 62 65 68 61 76 65 20 |may also| behave |
|000026e0| 64 69 66 66 65 72 65 6e | 74 6c 79 20 66 72 6f 6d |differen|tly from|
|000026f0| 20 5c 69 64 65 7b 65 71 | 76 3f 7d 20 6f 6e 20 65 | \ide{eq|v?} on e|
|00002700| 6d 70 74 79 0a 76 65 63 | 74 6f 72 73 20 61 6e 64 |mpty.vec|tors and|
|00002710| 20 65 6d 70 74 79 20 73 | 74 72 69 6e 67 73 2e 0a | empty s|trings..|
|00002720| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00002730| 28 65 71 3f 20 27 61 20 | 27 61 29 20 20 20 20 20 |(eq? 'a |'a) |
|00002740| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002750| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 0a 28 65 |\ev \sc|htrue.(e|
|00002760| 71 3f 20 27 28 61 29 20 | 27 28 61 29 29 20 20 20 |q? '(a) |'(a)) |
|00002770| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 5c 65 | | \e|
|00002780| 76 20 20 5c 75 6e 73 70 | 65 63 69 66 69 65 64 0a |v \unsp|ecified.|
|00002790| 28 65 71 3f 20 28 6c 69 | 73 74 20 27 61 29 20 28 |(eq? (li|st 'a) (|
|000027a0| 6c 69 73 74 20 27 61 29 | 29 20 20 20 20 20 20 20 |list 'a)|) |
|000027b0| 5c 65 76 20 20 5c 73 63 | 68 66 61 6c 73 65 0a 28 |\ev \sc|hfalse.(|
|000027c0| 65 71 3f 20 22 61 22 20 | 22 61 22 29 20 20 20 20 |eq? "a" |"a") |
|000027d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c | | \|
|000027e0| 65 76 20 20 5c 75 6e 73 | 70 65 63 69 66 69 65 64 |ev \uns|pecified|
|000027f0| 0a 28 65 71 3f 20 22 22 | 20 22 22 29 20 20 20 20 |.(eq? ""| "") |
|00002800| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002810| 20 5c 65 76 20 20 5c 75 | 6e 73 70 65 63 69 66 69 | \ev \u|nspecifi|
|00002820| 65 64 0a 28 65 71 3f 20 | 27 28 29 20 27 28 29 29 |ed.(eq? |'() '())|
|00002830| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002840| 20 20 20 5c 65 76 20 20 | 5c 73 63 68 74 72 75 65 | \ev |\schtrue|
|00002850| 0a 28 65 71 3f 20 32 20 | 32 29 20 20 20 20 20 20 |.(eq? 2 |2) |
|00002860| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002870| 20 5c 65 76 20 20 5c 75 | 6e 73 70 65 63 69 66 69 | \ev \u|nspecifi|
|00002880| 65 64 0a 28 65 71 3f 20 | 5c 23 5c 62 61 63 6b 77 |ed.(eq? |\#\backw|
|00002890| 68 61 63 6b 7b 7d 41 20 | 5c 23 5c 62 61 63 6b 77 |hack{}A |\#\backw|
|000028a0| 68 61 63 6b 7b 7d 41 29 | 20 5c 65 76 20 20 5c 75 |hack{}A)| \ev \u|
|000028b0| 6e 73 70 65 63 69 66 69 | 65 64 0a 28 65 71 3f 20 |nspecifi|ed.(eq? |
|000028c0| 63 61 72 20 63 61 72 29 | 20 20 20 20 20 20 20 20 |car car)| |
|000028d0| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 | | \ev |
|000028e0| 5c 73 63 68 74 72 75 65 | 0a 28 6c 65 74 20 28 28 |\schtrue|.(let ((|
|000028f0| 6e 20 28 2b 20 32 20 33 | 29 29 29 0a 20 20 28 65 |n (+ 2 3|))). (e|
|00002900| 71 3f 20 6e 20 6e 29 29 | 20 20 20 20 20 20 5c 65 |q? n n))| \e|
|00002910| 76 20 20 5c 75 6e 73 70 | 65 63 69 66 69 65 64 0a |v \unsp|ecified.|
|00002920| 28 6c 65 74 20 28 28 78 | 20 27 28 61 29 29 29 0a |(let ((x| '(a))).|
|00002930| 20 20 28 65 71 3f 20 78 | 20 78 29 29 20 20 20 20 | (eq? x| x)) |
|00002940| 20 20 5c 65 76 20 20 5c | 73 63 68 74 72 75 65 0a | \ev \|schtrue.|
|00002950| 28 6c 65 74 20 28 28 78 | 20 27 5c 23 28 29 29 29 |(let ((x| '\#()))|
|00002960| 0a 20 20 28 65 71 3f 20 | 78 20 78 29 29 20 20 20 |. (eq? |x x)) |
|00002970| 20 20 20 5c 65 76 20 20 | 5c 73 63 68 74 72 75 65 | \ev |\schtrue|
|00002980| 0a 28 6c 65 74 20 28 28 | 70 20 28 6c 61 6d 62 64 |.(let ((|p (lambd|
|00002990| 61 20 28 78 29 20 78 29 | 29 29 0a 20 20 28 65 71 |a (x) x)|)). (eq|
|000029a0| 3f 20 70 20 70 29 29 20 | 20 20 20 20 20 5c 65 76 |? p p)) | \ev|
|000029b0| 20 20 5c 73 63 68 74 72 | 75 65 25 0a 5c 65 6e 64 | \schtr|ue%.\end|
|000029c0| 7b 73 63 68 65 6d 65 7d | 0a 0a 5c 74 6f 64 6f 7b |{scheme}|..\todo{|
|000029d0| 4e 65 65 64 73 20 74 6f | 20 62 65 20 65 78 70 6c |Needs to| be expl|
|000029e0| 61 69 6e 65 64 20 62 65 | 74 74 65 72 20 61 62 6f |ained be|tter abo|
|000029f0| 76 65 2e 20 20 48 6f 77 | 20 63 61 6e 20 74 68 69 |ve. How| can thi|
|00002a00| 73 20 62 65 20 6d 61 64 | 65 20 74 6f 20 62 65 0a |s be mad|e to be.|
|00002a10| 6e 6f 74 20 63 6f 6e 66 | 75 73 69 6e 67 3f 20 20 |not conf|using? |
|00002a20| 41 20 74 61 62 6c 65 20 | 6d 61 79 62 65 3f 7d 0a |A table |maybe?}.|
|00002a30| 0a 5c 62 65 67 69 6e 7b | 6e 6f 74 65 7d 20 49 74 |.\begin{|note} It|
|00002a40| 20 77 69 6c 6c 20 75 73 | 75 61 6c 6c 79 20 62 65 | will us|ually be|
|00002a50| 20 70 6f 73 73 69 62 6c | 65 20 74 6f 20 69 6d 70 | possibl|e to imp|
|00002a60| 6c 65 6d 65 6e 74 20 5c | 69 64 65 7b 65 71 3f 7d |lement \|ide{eq?}|
|00002a70| 5c 20 6d 75 63 68 0a 6d | 6f 72 65 20 65 66 66 69 |\ much.m|ore effi|
|00002a80| 63 69 65 6e 74 6c 79 20 | 74 68 61 6e 20 5c 69 64 |ciently |than \id|
|00002a90| 65 7b 65 71 76 3f 7d 2c | 20 66 6f 72 20 65 78 61 |e{eqv?},| for exa|
|00002aa0| 6d 70 6c 65 2c 20 61 73 | 20 61 20 73 69 6d 70 6c |mple, as| a simpl|
|00002ab0| 65 20 70 6f 69 6e 74 65 | 72 0a 63 6f 6d 70 61 72 |e pointe|r.compar|
|00002ac0| 69 73 6f 6e 20 69 6e 73 | 74 65 61 64 20 6f 66 20 |ison ins|tead of |
|00002ad0| 61 73 20 73 6f 6d 65 20 | 6d 6f 72 65 20 63 6f 6d |as some |more com|
|00002ae0| 70 6c 69 63 61 74 65 64 | 20 6f 70 65 72 61 74 69 |plicated| operati|
|00002af0| 6f 6e 2e 20 20 4f 6e 65 | 20 72 65 61 73 6f 6e 20 |on. One| reason |
|00002b00| 69 73 0a 74 68 61 74 20 | 69 74 20 6d 61 79 20 6e |is.that |it may n|
|00002b10| 6f 74 20 62 65 20 70 6f | 73 73 69 62 6c 65 20 74 |ot be po|ssible t|
|00002b20| 6f 20 63 6f 6d 70 75 74 | 65 20 5c 69 64 65 7b 65 |o comput|e \ide{e|
|00002b30| 71 76 3f 7d 5c 20 6f 66 | 20 74 77 6f 20 6e 75 6d |qv?}\ of| two num|
|00002b40| 62 65 72 73 20 69 6e 0a | 63 6f 6e 73 74 61 6e 74 |bers in.|constant|
|00002b50| 20 74 69 6d 65 2c 20 77 | 68 65 72 65 61 73 20 5c | time, w|hereas \|
|00002b60| 69 64 65 7b 65 71 3f 7d | 5c 20 69 6d 70 6c 65 6d |ide{eq?}|\ implem|
|00002b70| 65 6e 74 65 64 20 61 73 | 20 70 6f 69 6e 74 65 72 |ented as| pointer|
|00002b80| 20 63 6f 6d 70 61 72 69 | 73 6f 6e 20 77 69 6c 6c | compari|son will|
|00002b90| 0a 61 6c 77 61 79 73 20 | 66 69 6e 69 73 68 20 69 |.always |finish i|
|00002ba0| 6e 20 63 6f 6e 73 74 61 | 6e 74 20 74 69 6d 65 2e |n consta|nt time.|
|00002bb0| 20 20 5c 69 64 65 7b 45 | 71 3f 7d 5c 20 6d 61 79 | \ide{E|q?}\ may|
|00002bc0| 20 62 65 20 75 73 65 64 | 20 6c 69 6b 65 20 5c 69 | be used| like \i|
|00002bd0| 64 65 7b 65 71 76 3f 7d | 5c 0a 69 6e 20 61 70 70 |de{eqv?}|\.in app|
|00002be0| 6c 69 63 61 74 69 6f 6e | 73 20 75 73 69 6e 67 20 |lication|s using |
|00002bf0| 70 72 6f 63 65 64 75 72 | 65 73 20 74 6f 20 69 6d |procedur|es to im|
|00002c00| 70 6c 65 6d 65 6e 74 20 | 6f 62 6a 65 63 74 73 20 |plement |objects |
|00002c10| 77 69 74 68 20 73 74 61 | 74 65 20 73 69 6e 63 65 |with sta|te since|
|00002c20| 0a 69 74 20 6f 62 65 79 | 73 20 74 68 65 20 73 61 |.it obey|s the sa|
|00002c30| 6d 65 20 63 6f 6e 73 74 | 72 61 69 6e 74 73 20 61 |me const|raints a|
|00002c40| 73 20 5c 69 64 65 7b 65 | 71 76 3f 7d 2e 20 20 5c |s \ide{e|qv?}. \|
|00002c50| 65 6e 64 7b 6e 6f 74 65 | 7d 0a 0a 5c 65 6e 64 7b |end{note|}..\end{|
|00002c60| 65 6e 74 72 79 7d 0a 0a | 0a 5c 62 65 67 69 6e 7b |entry}..|.\begin{|
|00002c70| 65 6e 74 72 79 7d 7b 25 | 0a 5c 70 72 6f 74 6f 7b |entry}{%|.\proto{|
|00002c80| 65 71 75 61 6c 3f 7d 7b | 20 5c 76 61 72 69 7b 6f |equal?}{| \vari{o|
|00002c90| 62 6a 7d 20 5c 76 61 72 | 69 69 7b 6f 62 6a 7d 7d |bj} \var|ii{obj}}|
|00002ca0| 7b 65 73 73 65 6e 74 69 | 61 6c 20 70 72 6f 63 65 |{essenti|al proce|
|00002cb0| 64 75 72 65 7d 7d 0a 0a | 5c 69 64 65 7b 45 71 75 |dure}}..|\ide{Equ|
|00002cc0| 61 6c 3f 7d 20 72 65 63 | 75 72 73 69 76 65 6c 79 |al?} rec|ursively|
|00002cd0| 20 63 6f 6d 70 61 72 65 | 73 20 74 68 65 20 63 6f | compare|s the co|
|00002ce0| 6e 74 65 6e 74 73 20 6f | 66 20 70 61 69 72 73 2c |ntents o|f pairs,|
|00002cf0| 20 76 65 63 74 6f 72 73 | 2c 20 61 6e 64 0a 73 74 | vectors|, and.st|
|00002d00| 72 69 6e 67 73 2c 20 61 | 70 70 6c 79 69 6e 67 20 |rings, a|pplying |
|00002d10| 5c 69 64 65 7b 65 71 76 | 3f 7d 20 6f 6e 20 6f 74 |\ide{eqv|?} on ot|
|00002d20| 68 65 72 20 6f 62 6a 65 | 63 74 73 20 73 75 63 68 |her obje|cts such|
|00002d30| 20 61 73 20 6e 75 6d 62 | 65 72 73 20 61 6e 64 20 | as numb|ers and |
|00002d40| 73 79 6d 62 6f 6c 73 2e | 0a 41 20 72 75 6c 65 20 |symbols.|.A rule |
|00002d50| 6f 66 20 74 68 75 6d 62 | 20 69 73 20 74 68 61 74 |of thumb| is that|
|00002d60| 20 6f 62 6a 65 63 74 73 | 20 61 72 65 20 67 65 6e | objects| are gen|
|00002d70| 65 72 61 6c 6c 79 20 5c | 69 64 65 7b 65 71 75 61 |erally \|ide{equa|
|00002d80| 6c 3f 7d 20 69 66 20 74 | 68 65 79 20 70 72 69 6e |l?} if t|hey prin|
|00002d90| 74 0a 74 68 65 20 73 61 | 6d 65 2e 20 20 5c 69 64 |t.the sa|me. \id|
|00002da0| 65 7b 45 71 75 61 6c 3f | 7d 5c 20 6d 61 79 20 66 |e{Equal?|}\ may f|
|00002db0| 61 69 6c 20 74 6f 20 74 | 65 72 6d 69 6e 61 74 65 |ail to t|erminate|
|00002dc0| 20 69 66 20 69 74 73 20 | 61 72 67 75 6d 65 6e 74 | if its |argument|
|00002dd0| 73 20 61 72 65 0a 63 69 | 72 63 75 6c 61 72 20 64 |s are.ci|rcular d|
|00002de0| 61 74 61 20 73 74 72 75 | 63 74 75 72 65 73 2e 0a |ata stru|ctures..|
|00002df0| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|00002e00| 28 65 71 75 61 6c 3f 20 | 27 61 20 27 61 29 20 20 |(equal? |'a 'a) |
|00002e10| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002e20| 5c 65 76 20 20 5c 73 63 | 68 74 72 75 65 0a 28 65 |\ev \sc|htrue.(e|
|00002e30| 71 75 61 6c 3f 20 27 28 | 61 29 20 27 28 61 29 29 |qual? '(|a) '(a))|
|00002e40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 5c 65 | | \e|
|00002e50| 76 20 20 5c 73 63 68 74 | 72 75 65 0a 28 65 71 75 |v \scht|rue.(equ|
|00002e60| 61 6c 3f 20 27 28 61 20 | 28 62 29 20 63 29 0a 20 |al? '(a |(b) c). |
|00002e70| 20 20 20 20 20 20 20 27 | 28 61 20 28 62 29 20 63 | '|(a (b) c|
|00002e80| 29 29 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c |)) | \|
|00002e90| 65 76 20 20 5c 73 63 68 | 74 72 75 65 0a 28 65 71 |ev \sch|true.(eq|
|00002ea0| 75 61 6c 3f 20 22 61 62 | 63 22 20 22 61 62 63 22 |ual? "ab|c" "abc"|
|00002eb0| 29 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 |) | \ev|
|00002ec0| 20 20 5c 73 63 68 74 72 | 75 65 0a 28 65 71 75 61 | \schtr|ue.(equa|
|00002ed0| 6c 3f 20 32 20 32 29 20 | 20 20 20 20 20 20 20 20 |l? 2 2) | |
|00002ee0| 20 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 | | \ev |
|00002ef0| 5c 73 63 68 74 72 75 65 | 0a 28 65 71 75 61 6c 3f |\schtrue|.(equal?|
|00002f00| 20 28 6d 61 6b 65 2d 76 | 65 63 74 6f 72 20 35 20 | (make-v|ector 5 |
|00002f10| 27 61 29 0a 20 20 20 20 | 20 20 20 20 28 6d 61 6b |'a). | (mak|
|00002f20| 65 2d 76 65 63 74 6f 72 | 20 35 20 27 61 29 29 20 |e-vector| 5 'a)) |
|00002f30| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 74 72 75 | \ev | \schtru|
|00002f40| 65 0a 28 65 71 75 61 6c | 3f 20 28 6c 61 6d 62 64 |e.(equal|? (lambd|
|00002f50| 61 20 28 78 29 20 78 29 | 0a 20 20 20 20 20 20 20 |a (x) x)|. |
|00002f60| 20 28 6c 61 6d 62 64 61 | 20 28 79 29 20 79 29 29 | (lambda| (y) y))|
|00002f70| 20 20 5c 65 76 20 20 5c | 75 6e 73 70 65 63 69 66 | \ev \|unspecif|
|00002f80| 69 65 64 25 0a 5c 65 6e | 64 7b 73 63 68 65 6d 65 |ied%.\en|d{scheme|
|00002f90| 7d 0a 0a 5c 65 6e 64 7b | 65 6e 74 72 79 7d 0a 0a |}..\end{|entry}..|
|00002fa0| 0a 5c 73 65 63 74 69 6f | 6e 7b 50 61 69 72 73 20 |.\sectio|n{Pairs |
|00002fb0| 61 6e 64 20 6c 69 73 74 | 73 7d 0a 5c 6c 61 62 65 |and list|s}.\labe|
|00002fc0| 6c 7b 6c 69 73 74 73 65 | 63 74 69 6f 6e 7d 0a 0a |l{listse|ction}..|
|00002fd0| 41 20 5c 64 65 66 69 6e | 69 6e 67 7b 70 61 69 72 |A \defin|ing{pair|
|00002fe0| 7d 20 28 73 6f 6d 65 74 | 69 6d 65 73 20 63 61 6c |} (somet|imes cal|
|00002ff0| 6c 65 64 20 61 20 5c 64 | 65 66 69 6e 69 6e 67 7b |led a \d|efining{|
|00003000| 64 6f 74 74 65 64 20 70 | 61 69 72 7d 29 20 69 73 |dotted p|air}) is|
|00003010| 20 61 0a 72 65 63 6f 72 | 64 20 73 74 72 75 63 74 | a.recor|d struct|
|00003020| 75 72 65 20 77 69 74 68 | 20 74 77 6f 20 66 69 65 |ure with| two fie|
|00003030| 6c 64 73 20 63 61 6c 6c | 65 64 20 74 68 65 20 63 |lds call|ed the c|
|00003040| 61 72 20 61 6e 64 20 63 | 64 72 20 66 69 65 6c 64 |ar and c|dr field|
|00003050| 73 20 28 66 6f 72 0a 68 | 69 73 74 6f 72 69 63 61 |s (for.h|istorica|
|00003060| 6c 20 72 65 61 73 6f 6e | 73 29 2e 20 20 50 61 69 |l reason|s). Pai|
|00003070| 72 73 20 61 72 65 20 63 | 72 65 61 74 65 64 20 62 |rs are c|reated b|
|00003080| 79 20 74 68 65 20 70 72 | 6f 63 65 64 75 72 65 20 |y the pr|ocedure |
|00003090| 5c 69 64 65 7b 63 6f 6e | 73 7d 2e 0a 54 68 65 20 |\ide{con|s}..The |
|000030a0| 63 61 72 20 61 6e 64 20 | 63 64 72 20 66 69 65 6c |car and |cdr fiel|
|000030b0| 64 73 20 61 72 65 20 61 | 63 63 65 73 73 65 64 20 |ds are a|ccessed |
|000030c0| 62 79 20 74 68 65 20 70 | 72 6f 63 65 64 75 72 65 |by the p|rocedure|
|000030d0| 73 20 5c 69 64 65 7b 63 | 61 72 7d 20 61 6e 64 0a |s \ide{c|ar} and.|
|000030e0| 5c 69 64 65 7b 63 64 72 | 7d 2e 20 20 54 68 65 20 |\ide{cdr|}. The |
|000030f0| 63 61 72 20 61 6e 64 20 | 63 64 72 20 66 69 65 6c |car and |cdr fiel|
|00003100| 64 73 20 61 72 65 20 61 | 73 73 69 67 6e 65 64 20 |ds are a|ssigned |
|00003110| 62 79 20 74 68 65 20 70 | 72 6f 63 65 64 75 72 65 |by the p|rocedure|
|00003120| 73 0a 5c 69 64 65 7b 73 | 65 74 2d 63 61 72 21 7d |s.\ide{s|et-car!}|
|00003130| 5c 20 61 6e 64 20 5c 69 | 64 65 7b 73 65 74 2d 63 |\ and \i|de{set-c|
|00003140| 64 72 21 7d 2e 0a 0a 50 | 61 69 72 73 20 61 72 65 |dr!}...P|airs are|
|00003150| 20 75 73 65 64 20 70 72 | 69 6d 61 72 69 6c 79 20 | used pr|imarily |
|00003160| 74 6f 20 72 65 70 72 65 | 73 65 6e 74 20 6c 69 73 |to repre|sent lis|
|00003170| 74 73 2e 20 20 41 20 6c | 69 73 74 20 63 61 6e 20 |ts. A l|ist can |
|00003180| 62 65 20 64 65 66 69 6e | 65 64 0a 72 65 63 75 72 |be defin|ed.recur|
|00003190| 73 69 76 65 6c 79 20 61 | 73 20 65 69 74 68 65 72 |sively a|s either|
|000031a0| 20 74 68 65 20 65 6d 70 | 74 79 20 6c 69 73 74 5c | the emp|ty list\|
|000031b0| 69 6e 64 65 78 7b 65 6d | 70 74 79 20 6c 69 73 74 |index{em|pty list|
|000031c0| 7d 20 6f 72 20 61 20 70 | 61 69 72 20 77 68 6f 73 |} or a p|air whos|
|000031d0| 65 20 63 64 72 20 69 73 | 20 61 20 6c 69 73 74 2e |e cdr is| a list.|
|000031e0| 20 20 54 68 65 0a 6f 62 | 6a 65 63 74 73 20 69 6e | The.ob|jects in|
|000031f0| 20 74 68 65 20 63 61 72 | 20 66 69 65 6c 64 73 20 | the car| fields |
|00003200| 6f 66 20 73 75 63 63 65 | 73 73 69 76 65 20 70 61 |of succe|ssive pa|
|00003210| 69 72 73 20 6f 66 20 61 | 20 6c 69 73 74 20 61 72 |irs of a| list ar|
|00003220| 65 20 74 68 65 20 65 6c | 65 6d 65 6e 74 73 0a 6f |e the el|ements.o|
|00003230| 66 20 74 68 65 20 6c 69 | 73 74 2e 20 20 46 6f 72 |f the li|st. For|
|00003240| 20 65 78 61 6d 70 6c 65 | 2c 20 61 20 74 77 6f 2d | example|, a two-|
|00003250| 65 6c 65 6d 65 6e 74 20 | 6c 69 73 74 20 69 73 20 |element |list is |
|00003260| 61 20 70 61 69 72 20 77 | 68 6f 73 65 20 63 61 72 |a pair w|hose car|
|00003270| 20 69 73 20 74 68 65 0a | 66 69 72 73 74 20 65 6c | is the.|first el|
|00003280| 65 6d 65 6e 74 20 61 6e | 64 20 77 68 6f 73 65 20 |ement an|d whose |
|00003290| 63 64 72 20 69 73 20 61 | 20 70 61 69 72 20 77 68 |cdr is a| pair wh|
|000032a0| 6f 73 65 20 63 61 72 20 | 69 73 20 74 68 65 20 73 |ose car |is the s|
|000032b0| 65 63 6f 6e 64 20 65 6c | 65 6d 65 6e 74 0a 61 6e |econd el|ement.an|
|000032c0| 64 20 77 68 6f 73 65 20 | 63 64 72 20 69 73 20 74 |d whose |cdr is t|
|000032d0| 68 65 20 65 6d 70 74 79 | 20 6c 69 73 74 2e 20 20 |he empty| list. |
|000032e0| 54 68 65 20 6c 65 6e 67 | 74 68 20 6f 66 20 61 20 |The leng|th of a |
|000032f0| 6c 69 73 74 20 69 73 20 | 74 68 65 20 6e 75 6d 62 |list is |the numb|
|00003300| 65 72 20 6f 66 0a 65 6c | 65 6d 65 6e 74 73 2c 20 |er of.el|ements, |
|00003310| 77 68 69 63 68 20 69 73 | 20 74 68 65 20 73 61 6d |which is| the sam|
|00003320| 65 20 61 73 20 74 68 65 | 20 6e 75 6d 62 65 72 20 |e as the| number |
|00003330| 6f 66 20 70 61 69 72 73 | 2e 0a 0a 54 68 65 20 65 |of pairs|...The e|
|00003340| 6d 70 74 79 20 6c 69 73 | 74 5c 6d 61 69 6e 69 6e |mpty lis|t\mainin|
|00003350| 64 65 78 7b 65 6d 70 74 | 79 20 6c 69 73 74 7d 20 |dex{empt|y list} |
|00003360| 69 73 20 61 20 73 70 65 | 63 69 61 6c 20 6f 62 6a |is a spe|cial obj|
|00003370| 65 63 74 20 6f 66 20 69 | 74 73 20 6f 77 6e 20 74 |ect of i|ts own t|
|00003380| 79 70 65 0a 28 69 74 20 | 69 73 20 6e 6f 74 20 61 |ype.(it |is not a|
|00003390| 20 70 61 69 72 29 3b 20 | 69 74 20 68 61 73 20 6e | pair); |it has n|
|000033a0| 6f 20 65 6c 65 6d 65 6e | 74 73 20 61 6e 64 20 69 |o elemen|ts and i|
|000033b0| 74 73 20 6c 65 6e 67 74 | 68 20 69 73 20 7a 65 72 |ts lengt|h is zer|
|000033c0| 6f 2e 0a 0a 54 68 65 20 | 6d 6f 73 74 20 67 65 6e |o...The |most gen|
|000033d0| 65 72 61 6c 20 6e 6f 74 | 61 74 69 6f 6e 20 28 65 |eral not|ation (e|
|000033e0| 78 74 65 72 6e 61 6c 20 | 72 65 70 72 65 73 65 6e |xternal |represen|
|000033f0| 74 61 74 69 6f 6e 29 20 | 66 6f 72 20 53 63 68 65 |tation) |for Sche|
|00003400| 6d 65 20 70 61 69 72 73 | 20 69 73 0a 74 68 65 20 |me pairs| is.the |
|00003410| 60 60 64 6f 74 74 65 64 | 27 27 20 6e 6f 74 61 74 |``dotted|'' notat|
|00003420| 69 6f 6e 20 5c 68 62 6f | 78 7b 5c 63 66 20 28 5c |ion \hbo|x{\cf (\|
|00003430| 76 61 72 69 7b 63 7d 20 | 2e 5c 20 5c 76 61 72 69 |vari{c} |.\ \vari|
|00003440| 69 7b 63 7d 29 7d 20 77 | 68 65 72 65 0a 5c 76 61 |i{c})} w|here.\va|
|00003450| 72 69 7b 63 7d 20 69 73 | 20 74 68 65 20 76 61 6c |ri{c} is| the val|
|00003460| 75 65 20 6f 66 20 74 68 | 65 20 63 61 72 20 66 69 |ue of th|e car fi|
|00003470| 65 6c 64 20 61 6e 64 20 | 5c 76 61 72 69 69 7b 63 |eld and |\varii{c|
|00003480| 7d 20 69 73 20 74 68 65 | 20 76 61 6c 75 65 20 6f |} is the| value o|
|00003490| 66 20 74 68 65 0a 63 64 | 72 20 66 69 65 6c 64 2e |f the.cd|r field.|
|000034a0| 20 20 46 6f 72 20 65 78 | 61 6d 70 6c 65 20 7b 5c | For ex|ample {\|
|000034b0| 63 66 20 28 34 20 2e 5c | 20 35 29 7d 20 69 73 20 |cf (4 .\| 5)} is |
|000034c0| 61 20 70 61 69 72 20 77 | 68 6f 73 65 20 63 61 72 |a pair w|hose car|
|000034d0| 20 69 73 20 34 20 61 6e | 64 20 77 68 6f 73 65 0a | is 4 an|d whose.|
|000034e0| 63 64 72 20 69 73 20 35 | 2e 20 20 4e 6f 74 65 20 |cdr is 5|. Note |
|000034f0| 74 68 61 74 20 7b 5c 63 | 66 20 28 34 20 2e 5c 20 |that {\c|f (4 .\ |
|00003500| 35 29 7d 20 69 73 20 74 | 68 65 20 65 78 74 65 72 |5)} is t|he exter|
|00003510| 6e 61 6c 20 72 65 70 72 | 65 73 65 6e 74 61 74 69 |nal repr|esentati|
|00003520| 6f 6e 20 6f 66 20 61 0a | 70 61 69 72 2c 20 6e 6f |on of a.|pair, no|
|00003530| 74 20 61 6e 20 65 78 70 | 72 65 73 73 69 6f 6e 20 |t an exp|ression |
|00003540| 74 68 61 74 20 65 76 61 | 6c 75 61 74 65 73 20 74 |that eva|luates t|
|00003550| 6f 20 61 20 70 61 69 72 | 2e 0a 0a 41 20 6d 6f 72 |o a pair|...A mor|
|00003560| 65 20 73 74 72 65 61 6d | 6c 69 6e 65 64 20 6e 6f |e stream|lined no|
|00003570| 74 61 74 69 6f 6e 20 63 | 61 6e 20 62 65 20 75 73 |tation c|an be us|
|00003580| 65 64 20 66 6f 72 20 6c | 69 73 74 73 3a 20 74 68 |ed for l|ists: th|
|00003590| 65 20 65 6c 65 6d 65 6e | 74 73 20 6f 66 20 74 68 |e elemen|ts of th|
|000035a0| 65 0a 6c 69 73 74 20 61 | 72 65 20 73 69 6d 70 6c |e.list a|re simpl|
|000035b0| 79 20 65 6e 63 6c 6f 73 | 65 64 20 69 6e 20 70 61 |y enclos|ed in pa|
|000035c0| 72 65 6e 74 68 65 73 65 | 73 20 61 6e 64 20 73 65 |renthese|s and se|
|000035d0| 70 61 72 61 74 65 64 20 | 62 79 20 73 70 61 63 65 |parated |by space|
|000035e0| 73 2e 20 20 54 68 65 0a | 65 6d 70 74 79 20 6c 69 |s. The.|empty li|
|000035f0| 73 74 5c 69 6e 64 65 78 | 7b 65 6d 70 74 79 20 6c |st\index|{empty l|
|00003600| 69 73 74 7d 20 69 73 20 | 77 72 69 74 74 65 6e 20 |ist} is |written |
|00003610| 7b 5c 74 74 28 29 7d 20 | 2e 20 20 46 6f 72 20 65 |{\tt()} |. For e|
|00003620| 78 61 6d 70 6c 65 2c 0a | 0a 5c 62 65 67 69 6e 7b |xample,.|.\begin{|
|00003630| 73 63 68 65 6d 65 7d 0a | 28 61 20 62 20 63 20 64 |scheme}.|(a b c d|
|00003640| 20 65 29 25 0a 5c 65 6e | 64 7b 73 63 68 65 6d 65 | e)%.\en|d{scheme|
|00003650| 7d 0a 0a 61 6e 64 0a 0a | 5c 62 65 67 69 6e 7b 73 |}..and..|\begin{s|
|00003660| 63 68 65 6d 65 7d 0a 28 | 61 20 2e 20 28 62 20 2e |cheme}.(|a . (b .|
|00003670| 20 28 63 20 2e 20 28 64 | 20 2e 20 28 65 20 2e 20 | (c . (d| . (e . |
|00003680| 28 29 29 29 29 29 29 25 | 0a 5c 65 6e 64 7b 73 63 |())))))%|.\end{sc|
|00003690| 68 65 6d 65 7d 0a 0a 61 | 72 65 20 65 71 75 69 76 |heme}..a|re equiv|
|000036a0| 61 6c 65 6e 74 20 6e 6f | 74 61 74 69 6f 6e 73 20 |alent no|tations |
|000036b0| 66 6f 72 20 61 20 6c 69 | 73 74 20 6f 66 20 73 79 |for a li|st of sy|
|000036c0| 6d 62 6f 6c 73 2e 0a 0a | 41 20 63 68 61 69 6e 20 |mbols...|A chain |
|000036d0| 6f 66 20 70 61 69 72 73 | 20 6e 6f 74 20 65 6e 64 |of pairs| not end|
|000036e0| 69 6e 67 20 69 6e 20 74 | 68 65 20 65 6d 70 74 79 |ing in t|he empty|
|000036f0| 20 6c 69 73 74 20 69 73 | 20 63 61 6c 6c 65 64 20 | list is| called |
|00003700| 61 6e 0a 5c 64 65 66 69 | 6e 69 6e 67 7b 69 6d 70 |an.\defi|ning{imp|
|00003710| 72 6f 70 65 72 20 6c 69 | 73 74 7d 2e 20 20 4e 6f |roper li|st}. No|
|00003720| 74 65 20 74 68 61 74 20 | 61 6e 20 69 6d 70 72 6f |te that |an impro|
|00003730| 70 65 72 20 6c 69 73 74 | 20 69 73 20 6e 6f 74 20 |per list| is not |
|00003740| 61 20 6c 69 73 74 2e 0a | 54 68 65 20 6c 69 73 74 |a list..|The list|
|00003750| 20 61 6e 64 20 64 6f 74 | 74 65 64 20 6e 6f 74 61 | and dot|ted nota|
|00003760| 74 69 6f 6e 73 20 63 61 | 6e 20 62 65 20 63 6f 6d |tions ca|n be com|
|00003770| 62 69 6e 65 64 20 74 6f | 20 72 65 70 72 65 73 65 |bined to| represe|
|00003780| 6e 74 20 69 6d 70 72 6f | 70 65 72 0a 6c 69 73 74 |nt impro|per.list|
|00003790| 73 3a 0a 0a 5c 62 65 67 | 69 6e 7b 73 63 68 65 6d |s:..\beg|in{schem|
|000037a0| 65 7d 0a 28 61 20 62 20 | 63 20 2e 20 64 29 25 0a |e}.(a b |c . d)%.|
|000037b0| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 0a 69 73 |\end{sch|eme}..is|
|000037c0| 20 65 71 75 69 76 61 6c | 65 6e 74 20 74 6f 0a 0a | equival|ent to..|
|000037d0| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 28 |\begin{s|cheme}.(|
|000037e0| 61 20 2e 20 28 62 20 2e | 20 28 63 20 2e 20 64 29 |a . (b .| (c . d)|
|000037f0| 29 29 25 0a 5c 65 6e 64 | 7b 73 63 68 65 6d 65 7d |))%.\end|{scheme}|
|00003800| 0a 0a 57 68 65 74 68 65 | 72 20 61 20 67 69 76 65 |..Whethe|r a give|
|00003810| 6e 20 70 61 69 72 20 69 | 73 20 61 20 6c 69 73 74 |n pair i|s a list|
|00003820| 20 64 65 70 65 6e 64 73 | 20 75 70 6f 6e 20 77 68 | depends| upon wh|
|00003830| 61 74 20 69 73 20 73 74 | 6f 72 65 64 20 69 6e 20 |at is st|ored in |
|00003840| 74 68 65 20 63 64 72 0a | 66 69 65 6c 64 2e 20 20 |the cdr.|field. |
|00003850| 57 68 65 6e 20 74 68 65 | 20 5c 69 64 65 7b 73 65 |When the| \ide{se|
|00003860| 74 2d 63 64 72 21 7d 20 | 70 72 6f 63 65 64 75 72 |t-cdr!} |procedur|
|00003870| 65 20 69 73 20 75 73 65 | 64 2c 20 61 6e 20 6f 62 |e is use|d, an ob|
|00003880| 6a 65 63 74 20 63 61 6e | 20 62 65 20 61 0a 6c 69 |ject can| be a.li|
|00003890| 73 74 20 6f 6e 65 20 6d | 6f 6d 65 6e 74 20 61 6e |st one m|oment an|
|000038a0| 64 20 6e 6f 74 20 74 68 | 65 20 6e 65 78 74 3a 0a |d not th|e next:.|
|000038b0| 0a 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |.\begin{|scheme}.|
|000038c0| 28 64 65 66 69 6e 65 20 | 78 20 28 6c 69 73 74 20 |(define |x (list |
|000038d0| 27 61 20 27 62 20 27 63 | 29 29 0a 28 64 65 66 69 |'a 'b 'c|)).(defi|
|000038e0| 6e 65 20 79 20 78 29 0a | 79 20 20 20 20 20 20 20 |ne y x).|y |
|000038f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003900| 5c 65 76 20 20 28 61 20 | 62 20 63 29 0a 28 73 65 |\ev (a |b c).(se|
|00003910| 74 2d 63 64 72 21 20 78 | 20 34 29 20 20 20 20 20 |t-cdr! x| 4) |
|00003920| 20 20 20 20 20 5c 65 76 | 20 20 5c 75 6e 73 70 65 | \ev| \unspe|
|00003930| 63 69 66 69 65 64 0a 78 | 20 20 20 20 20 20 20 20 |cified.x| |
|00003940| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c | | \|
|00003950| 65 76 20 20 28 61 20 2e | 20 34 29 0a 28 65 71 76 |ev (a .| 4).(eqv|
|00003960| 3f 20 78 20 79 29 20 20 | 20 20 20 20 20 20 20 20 |? x y) | |
|00003970| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 74 72 75 | \ev | \schtru|
|00003980| 65 0a 79 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |e.y | |
|00003990| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 28 | | \ev (|
|000039a0| 61 20 2e 20 34 29 25 0a | 5c 65 6e 64 7b 73 63 68 |a . 4)%.|\end{sch|
|000039b0| 65 6d 65 7d 0a 0a 49 74 | 20 69 73 20 6f 66 74 65 |eme}..It| is ofte|
|000039c0| 6e 20 63 6f 6e 76 65 6e | 69 65 6e 74 20 74 6f 20 |n conven|ient to |
|000039d0| 73 70 65 61 6b 20 6f 66 | 20 61 20 68 6f 6d 6f 67 |speak of| a homog|
|000039e0| 65 6e 65 6f 75 73 20 6c | 69 73 74 20 6f 66 20 6f |eneous l|ist of o|
|000039f0| 62 6a 65 63 74 73 0a 6f | 66 20 73 6f 6d 65 20 70 |bjects.o|f some p|
|00003a00| 61 72 74 69 63 75 6c 61 | 72 20 64 61 74 61 20 74 |articula|r data t|
|00003a10| 79 70 65 2c 20 61 73 20 | 66 6f 72 20 65 78 61 6d |ype, as |for exam|
|00003a20| 70 6c 65 20 5c 68 62 6f | 78 7b 5c 63 66 20 28 31 |ple \hbo|x{\cf (1|
|00003a30| 20 32 20 33 29 7d 20 69 | 73 20 61 20 6c 69 73 74 | 2 3)} i|s a list|
|00003a40| 20 6f 66 0a 69 6e 74 65 | 67 65 72 73 2e 20 20 54 | of.inte|gers. T|
|00003a50| 6f 20 62 65 20 6d 6f 72 | 65 20 70 72 65 63 69 73 |o be mor|e precis|
|00003a60| 65 2c 20 73 75 70 70 6f | 73 65 20 5c 76 61 72 7b |e, suppo|se \var{|
|00003a70| 44 7d 20 69 73 20 73 6f | 6d 65 20 64 61 74 61 20 |D} is so|me data |
|00003a80| 74 79 70 65 2e 20 20 28 | 41 6e 79 0a 70 72 65 64 |type. (|Any.pred|
|00003a90| 69 63 61 74 65 20 64 65 | 66 69 6e 65 73 20 61 20 |icate de|fines a |
|00003aa0| 64 61 74 61 20 74 79 70 | 65 20 63 6f 6e 73 69 73 |data typ|e consis|
|00003ab0| 74 69 6e 67 20 6f 66 20 | 74 68 6f 73 65 20 6f 62 |ting of |those ob|
|00003ac0| 6a 65 63 74 73 20 6f 66 | 20 77 68 69 63 68 20 74 |jects of| which t|
|00003ad0| 68 65 0a 70 72 65 64 69 | 63 61 74 65 20 69 73 20 |he.predi|cate is |
|00003ae0| 74 72 75 65 2e 29 20 20 | 54 68 65 6e 0a 0a 5c 62 |true.) |Then..\b|
|00003af0| 65 67 69 6e 7b 69 74 65 | 6d 69 7a 65 7d 0a 5c 69 |egin{ite|mize}.\i|
|00003b00| 74 65 6d 20 54 68 65 20 | 65 6d 70 74 79 20 6c 69 |tem The |empty li|
|00003b10| 73 74 20 69 73 20 61 20 | 6c 69 73 74 20 6f 66 20 |st is a |list of |
|00003b20| 5c 76 61 72 7b 44 7d 2e | 0a 5c 69 74 65 6d 20 49 |\var{D}.|.\item I|
|00003b30| 66 20 5c 76 61 72 7b 6c | 69 73 74 7d 20 69 73 20 |f \var{l|ist} is |
|00003b40| 61 20 6c 69 73 74 20 6f | 66 20 5c 76 61 72 7b 44 |a list o|f \var{D|
|00003b50| 7d 2c 20 74 68 65 6e 20 | 61 6e 79 20 70 61 69 72 |}, then |any pair|
|00003b60| 20 77 68 6f 73 65 20 63 | 64 72 20 69 73 0a 20 20 | whose c|dr is. |
|00003b70| 20 20 20 20 5c 76 61 72 | 7b 6c 69 73 74 7d 20 61 | \var|{list} a|
|00003b80| 6e 64 20 77 68 6f 73 65 | 20 63 61 72 20 69 73 20 |nd whose| car is |
|00003b90| 61 6e 20 65 6c 65 6d 65 | 6e 74 20 6f 66 20 74 68 |an eleme|nt of th|
|00003ba0| 65 20 64 61 74 61 20 74 | 79 70 65 20 5c 76 61 72 |e data t|ype \var|
|00003bb0| 7b 44 7d 20 69 73 20 61 | 6c 73 6f 20 61 0a 20 20 |{D} is a|lso a. |
|00003bc0| 20 20 20 20 6c 69 73 74 | 20 6f 66 20 5c 76 61 72 | list| of \var|
|00003bd0| 7b 44 7d 2e 0a 5c 69 74 | 65 6d 20 54 68 65 72 65 |{D}..\it|em There|
|00003be0| 20 61 72 65 20 6e 6f 20 | 6f 74 68 65 72 20 6c 69 | are no |other li|
|00003bf0| 73 74 73 20 6f 66 20 5c | 76 61 72 7b 44 7d 2e 0a |sts of \|var{D}..|
|00003c00| 5c 65 6e 64 7b 69 74 65 | 6d 69 7a 65 7d 0a 0a 57 |\end{ite|mize}..W|
|00003c10| 69 74 68 69 6e 20 6c 69 | 74 65 72 61 6c 20 65 78 |ithin li|teral ex|
|00003c20| 70 72 65 73 73 69 6f 6e | 73 20 61 6e 64 20 72 65 |pression|s and re|
|00003c30| 70 72 65 73 65 6e 74 61 | 74 69 6f 6e 73 20 6f 66 |presenta|tions of|
|00003c40| 20 6f 62 6a 65 63 74 73 | 20 72 65 61 64 20 62 79 | objects| read by|
|00003c50| 20 74 68 65 0a 5c 69 64 | 65 7b 72 65 61 64 7d 20 | the.\id|e{read} |
|00003c60| 70 72 6f 63 65 64 75 72 | 65 2c 20 74 68 65 20 66 |procedur|e, the f|
|00003c70| 6f 72 6d 73 20 5c 73 69 | 6e 67 6c 65 71 75 6f 74 |orms \si|nglequot|
|00003c80| 65 5c 68 79 70 65 72 7b | 64 61 74 75 6d 7d 5c 73 |e\hyper{|datum}\s|
|00003c90| 63 68 69 6e 64 65 78 7b | 27 7d 2c 0a 5c 62 61 63 |chindex{|'},.\bac|
|00003ca0| 6b 71 75 6f 74 65 5c 68 | 79 70 65 72 7b 64 61 74 |kquote\h|yper{dat|
|00003cb0| 75 6d 7d 2c 20 7b 5c 74 | 74 2c 7d 5c 68 79 70 65 |um}, {\t|t,}\hype|
|00003cc0| 72 7b 64 61 74 75 6d 7d | 5c 73 63 68 69 6e 64 65 |r{datum}|\schinde|
|00003cd0| 78 7b 2c 7d 2c 20 61 6e | 64 0a 7b 5c 74 74 2c 40 |x{,}, an|d.{\tt,@|
|00003ce0| 7d 5c 68 79 70 65 72 7b | 64 61 74 75 6d 7d 20 64 |}\hyper{|datum} d|
|00003cf0| 65 6e 6f 74 65 20 74 77 | 6f 2d 65 6c 65 5c 2d 6d |enote tw|o-ele\-m|
|00003d00| 65 6e 74 20 6c 69 73 74 | 73 20 77 68 6f 73 65 20 |ent list|s whose |
|00003d10| 66 69 72 73 74 20 65 6c | 65 6d 65 6e 74 73 20 61 |first el|ements a|
|00003d20| 72 65 0a 74 68 65 20 73 | 79 6d 62 6f 6c 73 20 5c |re.the s|ymbols \|
|00003d30| 69 64 65 7b 71 75 6f 74 | 65 7d 2c 20 5c 69 64 65 |ide{quot|e}, \ide|
|00003d40| 7b 71 75 61 73 69 71 75 | 6f 74 65 7d 2c 20 5c 68 |{quasiqu|ote}, \h|
|00003d50| 62 6f 78 7b 5c 69 64 65 | 7b 75 6e 71 75 6f 74 65 |box{\ide|{unquote|
|00003d60| 7d 7d 2c 20 61 6e 64 0a | 5c 69 64 65 7b 75 6e 71 |}}, and.|\ide{unq|
|00003d70| 75 6f 74 65 2d 73 70 6c | 69 63 69 6e 67 7d 2c 20 |uote-spl|icing}, |
|00003d80| 72 65 73 70 65 63 74 69 | 76 65 6c 79 2e 20 20 54 |respecti|vely. T|
|00003d90| 68 65 20 73 65 63 6f 6e | 64 20 65 6c 65 6d 65 6e |he secon|d elemen|
|00003da0| 74 20 69 6e 20 65 61 63 | 68 20 63 61 73 65 0a 69 |t in eac|h case.i|
|00003db0| 73 20 5c 68 79 70 65 72 | 7b 64 61 74 75 6d 7d 2e |s \hyper|{datum}.|
|00003dc0| 20 20 54 68 69 73 20 63 | 6f 6e 76 65 6e 74 69 6f | This c|onventio|
|00003dd0| 6e 20 69 73 20 73 75 70 | 70 6f 72 74 65 64 20 73 |n is sup|ported s|
|00003de0| 6f 20 74 68 61 74 20 61 | 72 62 69 74 72 61 72 79 |o that a|rbitrary|
|00003df0| 20 53 63 68 65 6d 65 0a | 70 72 6f 67 72 61 6d 73 | Scheme.|programs|
|00003e00| 20 6d 61 79 20 62 65 20 | 72 65 70 72 65 73 65 6e | may be |represen|
|00003e10| 74 65 64 20 61 73 20 6c | 69 73 74 73 2e 20 20 5c |ted as l|ists. \|
|00003e20| 74 6f 64 6f 7b 43 61 6e | 20 6f 72 20 6e 65 65 64 |todo{Can| or need|
|00003e30| 20 74 68 69 73 20 62 65 | 20 73 74 61 74 65 64 0a | this be| stated.|
|00003e40| 6d 6f 72 65 20 63 61 72 | 65 66 75 6c 6c 79 3f 7d |more car|efully?}|
|00003e50| 20 54 68 61 74 20 69 73 | 2c 20 61 63 63 6f 72 64 | That is|, accord|
|00003e60| 69 6e 67 20 74 6f 20 53 | 63 68 65 6d 65 27 73 20 |ing to S|cheme's |
|00003e70| 67 72 61 6d 6d 61 72 2c | 20 65 76 65 72 79 0a 5c |grammar,| every.\|
|00003e80| 6d 65 74 61 7b 65 78 70 | 72 65 73 73 69 6f 6e 7d |meta{exp|ression}|
|00003e90| 20 69 73 20 61 6c 73 6f | 20 61 20 5c 6d 65 74 61 | is also| a \meta|
|00003ea0| 7b 64 61 74 75 6d 7d 20 | 28 73 65 65 20 73 65 63 |{datum} |(see sec|
|00003eb0| 74 69 6f 6e 7e 5c 72 65 | 66 7b 64 61 74 75 6d 7d |tion~\re|f{datum}|
|00003ec0| 29 2e 0a 41 6d 6f 6e 67 | 20 6f 74 68 65 72 20 74 |)..Among| other t|
|00003ed0| 68 69 6e 67 73 2c 20 74 | 68 69 73 20 70 65 72 6d |hings, t|his perm|
|00003ee0| 69 74 73 20 74 68 65 20 | 75 73 65 20 6f 66 20 74 |its the |use of t|
|00003ef0| 68 65 20 5c 69 64 65 7b | 72 65 61 64 7d 20 70 72 |he \ide{|read} pr|
|00003f00| 6f 63 65 64 75 72 65 20 | 74 6f 0a 70 61 72 73 65 |ocedure |to.parse|
|00003f10| 20 53 63 68 65 6d 65 20 | 70 72 6f 67 72 61 6d 73 | Scheme |programs|
|00003f20| 2e 20 20 53 65 65 20 73 | 65 63 74 69 6f 6e 7e 5c |. See s|ection~\|
|00003f30| 72 65 66 7b 65 78 74 65 | 72 6e 61 6c 72 65 70 73 |ref{exte|rnalreps|
|00003f40| 7d 2e 20 0a 20 0a 0a 5c | 62 65 67 69 6e 7b 65 6e |}. . ..\|begin{en|
|00003f50| 74 72 79 7d 7b 25 0a 5c | 70 72 6f 74 6f 7b 70 61 |try}{%.\|proto{pa|
|00003f60| 69 72 3f 7d 7b 20 6f 62 | 6a 7d 7b 65 73 73 65 6e |ir?}{ ob|j}{essen|
|00003f70| 74 69 61 6c 20 70 72 6f | 63 65 64 75 72 65 7d 7d |tial pro|cedure}}|
|00003f80| 0a 0a 5c 69 64 65 7b 50 | 61 69 72 3f 7d 20 72 65 |..\ide{P|air?} re|
|00003f90| 74 75 72 6e 73 20 5c 73 | 63 68 74 72 75 65 7b 7d |turns \s|chtrue{}|
|00003fa0| 20 69 66 20 5c 76 61 72 | 7b 6f 62 6a 7d 20 69 73 | if \var|{obj} is|
|00003fb0| 20 61 20 70 61 69 72 2c | 20 61 6e 64 20 6f 74 68 | a pair,| and oth|
|00003fc0| 65 72 77 69 73 65 0a 72 | 65 74 75 72 6e 73 20 5c |erwise.r|eturns \|
|00003fd0| 73 63 68 66 61 6c 73 65 | 2e 0a 0a 5c 62 65 67 69 |schfalse|...\begi|
|00003fe0| 6e 7b 73 63 68 65 6d 65 | 7d 0a 28 70 61 69 72 3f |n{scheme|}.(pair?|
|00003ff0| 20 27 28 61 20 2e 20 62 | 29 29 20 20 20 20 20 20 | '(a . b|)) |
|00004000| 20 20 5c 65 76 20 20 5c | 73 63 68 74 72 75 65 0a | \ev \|schtrue.|
|00004010| 28 70 61 69 72 3f 20 27 | 28 61 20 62 20 63 29 29 |(pair? '|(a b c))|
|00004020| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 5c 73 63 | |\ev \sc|
|00004030| 68 74 72 75 65 0a 28 70 | 61 69 72 3f 20 27 28 29 |htrue.(p|air? '()|
|00004040| 29 20 20 20 20 20 20 20 | 20 20 20 20 20 20 5c 65 |) | \e|
|00004050| 76 20 20 5c 73 63 68 66 | 61 6c 73 65 0a 28 70 61 |v \schf|alse.(pa|
|00004060| 69 72 3f 20 27 5c 23 28 | 61 20 62 29 29 20 20 20 |ir? '\#(|a b)) |
|00004070| 20 20 20 20 20 20 5c 65 | 76 20 20 5c 73 63 68 66 | \e|v \schf|
|00004080| 61 6c 73 65 25 0a 5c 65 | 6e 64 7b 73 63 68 65 6d |alse%.\e|nd{schem|
|00004090| 65 7d 0a 5c 65 6e 64 7b | 65 6e 74 72 79 7d 0a 0a |e}.\end{|entry}..|
|000040a0| 0a 5c 62 65 67 69 6e 7b | 65 6e 74 72 79 7d 7b 25 |.\begin{|entry}{%|
|000040b0| 0a 5c 70 72 6f 74 6f 7b | 63 6f 6e 73 7d 7b 20 5c |.\proto{|cons}{ \|
|000040c0| 76 61 72 69 7b 6f 62 6a | 7d 20 5c 76 61 72 69 69 |vari{obj|} \varii|
|000040d0| 7b 6f 62 6a 7d 7d 7b 65 | 73 73 65 6e 74 69 61 6c |{obj}}{e|ssential|
|000040e0| 20 70 72 6f 63 65 64 75 | 72 65 7d 7d 0a 0a 52 65 | procedu|re}}..Re|
|000040f0| 74 75 72 6e 73 20 61 20 | 6e 65 77 6c 79 20 61 6c |turns a |newly al|
|00004100| 6c 6f 63 61 74 65 64 20 | 70 61 69 72 20 77 68 6f |located |pair who|
|00004110| 73 65 20 63 61 72 20 69 | 73 20 5c 76 61 72 69 7b |se car i|s \vari{|
|00004120| 6f 62 6a 7d 20 61 6e 64 | 20 77 68 6f 73 65 20 63 |obj} and| whose c|
|00004130| 64 72 20 69 73 0a 5c 76 | 61 72 69 69 7b 6f 62 6a |dr is.\v|arii{obj|
|00004140| 7d 2e 20 20 54 68 65 20 | 70 61 69 72 20 69 73 20 |}. The |pair is |
|00004150| 67 75 61 72 61 6e 74 65 | 65 64 20 74 6f 20 62 65 |guarante|ed to be|
|00004160| 20 64 69 66 66 65 72 65 | 6e 74 20 28 69 6e 20 74 | differe|nt (in t|
|00004170| 68 65 20 73 65 6e 73 65 | 20 6f 66 0a 5c 69 64 65 |he sense| of.\ide|
|00004180| 7b 65 71 76 3f 7d 29 20 | 66 72 6f 6d 20 65 76 65 |{eqv?}) |from eve|
|00004190| 72 79 20 65 78 69 73 74 | 69 6e 67 20 6f 62 6a 65 |ry exist|ing obje|
|000041a0| 63 74 2e 0a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |ct...\be|gin{sche|
|000041b0| 6d 65 7d 0a 28 63 6f 6e | 73 20 27 61 20 27 28 29 |me}.(con|s 'a '()|
|000041c0| 29 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 |) | \ev |
|000041d0| 20 28 61 29 0a 28 63 6f | 6e 73 20 27 28 61 29 20 | (a).(co|ns '(a) |
|000041e0| 27 28 62 20 63 20 64 29 | 29 20 20 20 20 5c 65 76 |'(b c d)|) \ev|
|000041f0| 20 20 28 28 61 29 20 62 | 20 63 20 64 29 0a 28 63 | ((a) b| c d).(c|
|00004200| 6f 6e 73 20 22 61 22 20 | 27 28 62 20 63 29 29 20 |ons "a" |'(b c)) |
|00004210| 20 20 20 20 20 20 5c 65 | 76 20 20 28 22 61 22 20 | \e|v ("a" |
|00004220| 62 20 63 29 0a 28 63 6f | 6e 73 20 27 61 20 33 29 |b c).(co|ns 'a 3)|
|00004230| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 | | \ev|
|00004240| 20 20 28 61 20 2e 20 33 | 29 0a 28 63 6f 6e 73 20 | (a . 3|).(cons |
|00004250| 27 28 61 20 62 29 20 27 | 63 29 20 20 20 20 20 20 |'(a b) '|c) |
|00004260| 20 20 5c 65 76 20 20 28 | 28 61 20 62 29 20 2e 20 | \ev (|(a b) . |
|00004270| 63 29 25 0a 5c 65 6e 64 | 7b 73 63 68 65 6d 65 7d |c)%.\end|{scheme}|
|00004280| 0a 5c 65 6e 64 7b 65 6e | 74 72 79 7d 0a 0a 0a 5c |.\end{en|try}...\|
|00004290| 62 65 67 69 6e 7b 65 6e | 74 72 79 7d 7b 25 0a 5c |begin{en|try}{%.\|
|000042a0| 70 72 6f 74 6f 7b 63 61 | 72 7d 7b 20 70 61 69 72 |proto{ca|r}{ pair|
|000042b0| 7d 7b 65 73 73 65 6e 74 | 69 61 6c 20 70 72 6f 63 |}{essent|ial proc|
|000042c0| 65 64 75 72 65 7d 7d 0a | 0a 5c 6e 6f 64 6f 6d 61 |edure}}.|.\nodoma|
|000042d0| 69 6e 7b 5c 76 61 72 7b | 50 61 69 72 7d 20 6d 75 |in{\var{|Pair} mu|
|000042e0| 73 74 20 62 65 20 61 20 | 70 61 69 72 2e 7d 0a 52 |st be a |pair.}.R|
|000042f0| 65 74 75 72 6e 73 20 74 | 68 65 20 63 6f 6e 74 65 |eturns t|he conte|
|00004300| 6e 74 73 20 6f 66 20 74 | 68 65 20 63 61 72 20 66 |nts of t|he car f|
|00004310| 69 65 6c 64 20 6f 66 20 | 5c 76 61 72 7b 70 61 69 |ield of |\var{pai|
|00004320| 72 7d 2e 20 20 4e 6f 74 | 65 20 74 68 61 74 20 69 |r}. Not|e that i|
|00004330| 74 20 69 73 20 61 6e 0a | 65 72 72 6f 72 20 74 6f |t is an.|error to|
|00004340| 20 74 61 6b 65 20 74 68 | 65 20 63 61 72 20 6f 66 | take th|e car of|
|00004350| 20 74 68 65 20 65 6d 70 | 74 79 20 6c 69 73 74 5c | the emp|ty list\|
|00004360| 69 6e 64 65 78 7b 65 6d | 70 74 79 20 6c 69 73 74 |index{em|pty list|
|00004370| 7d 2e 0a 0a 5c 62 65 67 | 69 6e 7b 73 63 68 65 6d |}...\beg|in{schem|
|00004380| 65 7d 0a 28 63 61 72 20 | 27 28 61 20 62 20 63 29 |e}.(car |'(a b c)|
|00004390| 29 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 |) | \ev |
|000043a0| 61 0a 28 63 61 72 20 27 | 28 28 61 29 20 62 20 63 |a.(car '|((a) b c|
|000043b0| 20 64 29 29 20 20 20 20 | 20 20 5c 65 76 20 20 28 | d)) | \ev (|
|000043c0| 61 29 0a 28 63 61 72 20 | 27 28 31 20 2e 20 32 29 |a).(car |'(1 . 2)|
|000043d0| 29 20 20 20 20 20 20 20 | 20 20 20 5c 65 76 20 20 |) | \ev |
|000043e0| 31 0a 28 63 61 72 20 27 | 28 29 29 20 20 20 20 20 |1.(car '|()) |
|000043f0| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 5c | | \ev \|
|00004400| 73 63 68 65 72 72 6f 72 | 25 0a 5c 65 6e 64 7b 73 |scherror|%.\end{s|
|00004410| 63 68 65 6d 65 7d 0a 20 | 0a 5c 65 6e 64 7b 65 6e |cheme}. |.\end{en|
|00004420| 74 72 79 7d 0a 0a 0a 5c | 62 65 67 69 6e 7b 65 6e |try}...\|begin{en|
|00004430| 74 72 79 7d 7b 25 0a 5c | 70 72 6f 74 6f 7b 63 64 |try}{%.\|proto{cd|
|00004440| 72 7d 7b 20 70 61 69 72 | 7d 7b 65 73 73 65 6e 74 |r}{ pair|}{essent|
|00004450| 69 61 6c 20 70 72 6f 63 | 65 64 75 72 65 7d 7d 0a |ial proc|edure}}.|
|00004460| 0a 5c 6e 6f 64 6f 6d 61 | 69 6e 7b 5c 76 61 72 7b |.\nodoma|in{\var{|
|00004470| 50 61 69 72 7d 20 6d 75 | 73 74 20 62 65 20 61 20 |Pair} mu|st be a |
|00004480| 70 61 69 72 2e 7d 0a 52 | 65 74 75 72 6e 73 20 74 |pair.}.R|eturns t|
|00004490| 68 65 20 63 6f 6e 74 65 | 6e 74 73 20 6f 66 20 74 |he conte|nts of t|
|000044a0| 68 65 20 63 64 72 20 66 | 69 65 6c 64 20 6f 66 20 |he cdr f|ield of |
|000044b0| 5c 76 61 72 7b 70 61 69 | 72 7d 2e 0a 4e 6f 74 65 |\var{pai|r}..Note|
|000044c0| 20 74 68 61 74 20 69 74 | 20 69 73 20 61 6e 20 65 | that it| is an e|
|000044d0| 72 72 6f 72 20 74 6f 20 | 74 61 6b 65 20 74 68 65 |rror to |take the|
|000044e0| 20 63 64 72 20 6f 66 20 | 74 68 65 20 65 6d 70 74 | cdr of |the empt|
|000044f0| 79 20 6c 69 73 74 2e 0a | 0a 5c 62 65 67 69 6e 7b |y list..|.\begin{|
|00004500| 73 63 68 65 6d 65 7d 0a | 28 63 64 72 20 27 28 28 |scheme}.|(cdr '((|
|00004510| 61 29 20 62 20 63 20 64 | 29 29 20 20 20 20 20 20 |a) b c d|)) |
|00004520| 5c 65 76 20 20 28 62 20 | 63 20 64 29 0a 28 63 64 |\ev (b |c d).(cd|
|00004530| 72 20 27 28 31 20 2e 20 | 32 29 29 20 20 20 20 20 |r '(1 . |2)) |
|00004540| 20 20 20 20 20 5c 65 76 | 20 20 32 0a 28 63 64 72 | \ev| 2.(cdr|
|00004550| 20 27 28 29 29 20 20 20 | 20 20 20 20 20 20 20 20 | '()) | |
|00004560| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 65 72 72 | \ev | \scherr|
|00004570| 6f 72 25 0a 5c 65 6e 64 | 7b 73 63 68 65 6d 65 7d |or%.\end|{scheme}|
|00004580| 0a 20 0a 5c 65 6e 64 7b | 65 6e 74 72 79 7d 0a 0a |. .\end{|entry}..|
|00004590| 0a 5c 62 65 67 69 6e 7b | 65 6e 74 72 79 7d 7b 25 |.\begin{|entry}{%|
|000045a0| 0a 5c 70 72 6f 74 6f 7b | 73 65 74 2d 63 61 72 21 |.\proto{|set-car!|
|000045b0| 7d 7b 20 70 61 69 72 20 | 6f 62 6a 7d 7b 65 73 73 |}{ pair |obj}{ess|
|000045c0| 65 6e 74 69 61 6c 20 70 | 72 6f 63 65 64 75 72 65 |ential p|rocedure|
|000045d0| 7d 7d 0a 0a 5c 6e 6f 64 | 6f 6d 61 69 6e 7b 5c 76 |}}..\nod|omain{\v|
|000045e0| 61 72 7b 50 61 69 72 7d | 20 6d 75 73 74 20 62 65 |ar{Pair}| must be|
|000045f0| 20 61 20 70 61 69 72 2e | 7d 20 20 0a 53 74 6f 72 | a pair.|} .Stor|
|00004600| 65 73 20 5c 76 61 72 7b | 6f 62 6a 7d 20 69 6e 20 |es \var{|obj} in |
|00004610| 74 68 65 20 63 61 72 20 | 66 69 65 6c 64 20 6f 66 |the car |field of|
|00004620| 20 5c 76 61 72 7b 70 61 | 69 72 7d 2e 0a 54 68 65 | \var{pa|ir}..The|
|00004630| 20 76 61 6c 75 65 20 72 | 65 74 75 72 6e 65 64 20 | value r|eturned |
|00004640| 62 79 20 5c 69 64 65 7b | 73 65 74 2d 63 61 72 21 |by \ide{|set-car!|
|00004650| 7d 5c 20 69 73 20 75 6e | 73 70 65 63 69 66 69 65 |}\ is un|specifie|
|00004660| 64 2e 20 20 25 20 3c 21 | 3e 0a 25 54 68 69 73 20 |d. % <!|>.%This |
|00004670| 70 72 6f 63 65 64 75 72 | 65 20 63 61 6e 20 62 65 |procedur|e can be|
|00004680| 20 76 65 72 79 20 63 6f | 6e 66 75 73 69 6e 67 20 | very co|nfusing |
|00004690| 69 66 20 75 73 65 64 20 | 69 6e 64 69 73 63 72 69 |if used |indiscri|
|000046a0| 6d 69 6e 61 74 65 6c 79 | 2e 0a 0a 5c 65 6e 64 7b |minately|...\end{|
|000046b0| 65 6e 74 72 79 7d 0a 0a | 0a 5c 62 65 67 69 6e 7b |entry}..|.\begin{|
|000046c0| 65 6e 74 72 79 7d 7b 25 | 0a 5c 70 72 6f 74 6f 7b |entry}{%|.\proto{|
|000046d0| 73 65 74 2d 63 64 72 21 | 7d 7b 20 70 61 69 72 20 |set-cdr!|}{ pair |
|000046e0| 6f 62 6a 7d 7b 65 73 73 | 65 6e 74 69 61 6c 20 70 |obj}{ess|ential p|
|000046f0| 72 6f 63 65 64 75 72 65 | 7d 7d 0a 0a 5c 6e 6f 64 |rocedure|}}..\nod|
|00004700| 6f 6d 61 69 6e 7b 5c 76 | 61 72 7b 50 61 69 72 7d |omain{\v|ar{Pair}|
|00004710| 20 6d 75 73 74 20 62 65 | 20 61 20 70 61 69 72 2e | must be| a pair.|
|00004720| 7d 0a 53 74 6f 72 65 73 | 20 5c 76 61 72 7b 6f 62 |}.Stores| \var{ob|
|00004730| 6a 7d 20 69 6e 20 74 68 | 65 20 63 64 72 20 66 69 |j} in th|e cdr fi|
|00004740| 65 6c 64 20 6f 66 20 5c | 76 61 72 7b 70 61 69 72 |eld of \|var{pair|
|00004750| 7d 2e 0a 54 68 65 20 76 | 61 6c 75 65 20 72 65 74 |}..The v|alue ret|
|00004760| 75 72 6e 65 64 20 62 79 | 20 5c 69 64 65 7b 73 65 |urned by| \ide{se|
|00004770| 74 2d 63 64 72 21 7d 5c | 20 69 73 20 75 6e 73 70 |t-cdr!}\| is unsp|
|00004780| 65 63 69 66 69 65 64 2e | 20 20 25 20 3c 21 3e 0a |ecified.| % <!>.|
|00004790| 25 54 68 69 73 20 70 72 | 6f 63 65 64 75 72 65 20 |%This pr|ocedure |
|000047a0| 63 61 6e 20 62 65 20 76 | 65 72 79 20 63 6f 6e 66 |can be v|ery conf|
|000047b0| 75 73 69 6e 67 20 69 66 | 20 75 73 65 64 20 69 6e |using if| used in|
|000047c0| 64 69 73 63 72 69 6d 69 | 6e 61 74 65 6c 79 2e 0a |discrimi|nately..|
|000047d0| 0a 5c 65 6e 64 7b 65 6e | 74 72 79 7d 0a 0a 5c 73 |.\end{en|try}..\s|
|000047e0| 65 74 62 6f 78 30 5c 68 | 62 6f 78 7b 5c 74 74 28 |etbox0\h|box{\tt(|
|000047f0| 63 61 64 72 20 5c 76 61 | 72 7b 70 61 69 72 7d 29 |cadr \va|r{pair})|
|00004800| 7d 0a 5c 73 65 74 62 6f | 78 31 5c 68 62 6f 78 7b |}.\setbo|x1\hbox{|
|00004810| 65 73 73 65 6e 74 69 61 | 6c 20 70 72 6f 63 65 64 |essentia|l proced|
|00004820| 75 72 65 7d 0a 0a 0a 5c | 62 65 67 69 6e 7b 65 6e |ure}...\|begin{en|
|00004830| 74 72 79 7d 7b 25 0a 5c | 70 72 6f 74 6f 7b 63 61 |try}{%.\|proto{ca|
|00004840| 61 72 7d 7b 20 70 61 69 | 72 7d 7b 65 73 73 65 6e |ar}{ pai|r}{essen|
|00004850| 74 69 61 6c 20 70 72 6f | 63 65 64 75 72 65 7d 0a |tial pro|cedure}.|
|00004860| 5c 70 72 6f 74 6f 7b 63 | 61 64 72 7d 7b 20 70 61 |\proto{c|adr}{ pa|
|00004870| 69 72 7d 7b 65 73 73 65 | 6e 74 69 61 6c 20 70 72 |ir}{esse|ntial pr|
|00004880| 6f 63 65 64 75 72 65 7d | 0a 5c 70 70 72 6f 74 6f |ocedure}|.\pproto|
|00004890| 7b 5c 68 62 6f 78 20 74 | 6f 20 31 5c 77 64 30 20 |{\hbox t|o 1\wd0 |
|000048a0| 7b 5c 68 66 69 6c 24 5c | 76 64 6f 74 73 24 5c 68 |{\hfil$\|vdots$\h|
|000048b0| 66 69 6c 7d 7d 7b 5c 68 | 62 6f 78 20 74 6f 20 31 |fil}}{\h|box to 1|
|000048c0| 5c 77 64 31 20 7b 5c 68 | 66 69 6c 24 5c 76 64 6f |\wd1 {\h|fil$\vdo|
|000048d0| 74 73 24 5c 68 66 69 6c | 7d 7d 0a 5c 70 72 6f 74 |ts$\hfil|}}.\prot|
|000048e0| 6f 7b 63 64 64 64 61 72 | 7d 7b 20 70 61 69 72 7d |o{cdddar|}{ pair}|
|000048f0| 7b 65 73 73 65 6e 74 69 | 61 6c 20 70 72 6f 63 65 |{essenti|al proce|
|00004900| 64 75 72 65 7d 0a 5c 70 | 72 6f 74 6f 7b 63 64 64 |dure}.\p|roto{cdd|
|00004910| 64 64 72 7d 7b 20 70 61 | 69 72 7d 7b 65 73 73 65 |ddr}{ pa|ir}{esse|
|00004920| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00004930| 7d 0a 0a 54 68 65 73 65 | 20 70 72 6f 63 65 64 75 |}..These| procedu|
|00004940| 72 65 73 20 61 72 65 20 | 63 6f 6d 70 6f 73 69 74 |res are |composit|
|00004950| 69 6f 6e 73 20 6f 66 20 | 5c 69 64 65 7b 63 61 72 |ions of |\ide{car|
|00004960| 7d 20 61 6e 64 20 5c 69 | 64 65 7b 63 64 72 7d 2c |} and \i|de{cdr},|
|00004970| 20 77 68 65 72 65 0a 66 | 6f 72 20 65 78 61 6d 70 | where.f|or examp|
|00004980| 6c 65 20 5c 69 64 65 7b | 63 61 64 64 72 7d 20 63 |le \ide{|caddr} c|
|00004990| 6f 75 6c 64 20 62 65 20 | 64 65 66 69 6e 65 64 20 |ould be |defined |
|000049a0| 62 79 0a 0a 5c 62 65 67 | 69 6e 7b 73 63 68 65 6d |by..\beg|in{schem|
|000049b0| 65 7d 0a 28 64 65 66 69 | 6e 65 20 63 61 64 64 72 |e}.(defi|ne caddr|
|000049c0| 20 28 6c 61 6d 62 64 61 | 20 28 78 29 20 28 63 61 | (lambda| (x) (ca|
|000049d0| 72 20 28 63 64 72 20 28 | 63 64 72 20 78 29 29 29 |r (cdr (|cdr x)))|
|000049e0| 29 29 7b 5c 72 6d 2e 7d | 25 0a 5c 65 6e 64 7b 73 |)){\rm.}|%.\end{s|
|000049f0| 63 68 65 6d 65 7d 0a 0a | 41 72 62 69 74 72 61 72 |cheme}..|Arbitrar|
|00004a00| 79 20 63 6f 6d 70 6f 73 | 69 74 69 6f 6e 73 2c 20 |y compos|itions, |
|00004a10| 75 70 20 74 6f 20 66 6f | 75 72 20 64 65 65 70 2c |up to fo|ur deep,|
|00004a20| 20 61 72 65 20 70 72 6f | 76 69 64 65 64 2e 20 20 | are pro|vided. |
|00004a30| 54 68 65 72 65 20 61 72 | 65 0a 74 77 65 6e 74 79 |There ar|e.twenty|
|00004a40| 2d 65 69 67 68 74 20 6f | 66 20 74 68 65 73 65 20 |-eight o|f these |
|00004a50| 70 72 6f 63 65 64 75 72 | 65 73 20 69 6e 20 61 6c |procedur|es in al|
|00004a60| 6c 2e 0a 0a 5c 65 6e 64 | 7b 65 6e 74 72 79 7d 0a |l...\end|{entry}.|
|00004a70| 0a 0a 5c 62 65 67 69 6e | 7b 65 6e 74 72 79 7d 7b |..\begin|{entry}{|
|00004a80| 25 0a 5c 70 72 6f 74 6f | 7b 6e 75 6c 6c 3f 7d 7b |%.\proto|{null?}{|
|00004a90| 20 6f 62 6a 7d 7b 65 73 | 73 65 6e 74 69 61 6c 20 | obj}{es|sential |
|00004aa0| 70 72 6f 63 65 64 75 72 | 65 7d 7d 0a 0a 52 65 74 |procedur|e}}..Ret|
|00004ab0| 75 72 6e 73 20 5c 73 63 | 68 74 72 75 65 7b 7d 20 |urns \sc|htrue{} |
|00004ac0| 69 66 20 5c 76 61 72 7b | 6f 62 6a 7d 20 69 73 20 |if \var{|obj} is |
|00004ad0| 74 68 65 20 65 6d 70 74 | 79 20 6c 69 73 74 5c 69 |the empt|y list\i|
|00004ae0| 6e 64 65 78 7b 65 6d 70 | 74 79 20 6c 69 73 74 7d |ndex{emp|ty list}|
|00004af0| 2c 0a 6f 74 68 65 72 77 | 69 73 65 20 72 65 74 75 |,.otherw|ise retu|
|00004b00| 72 6e 73 20 5c 73 63 68 | 66 61 6c 73 65 2e 20 20 |rns \sch|false. |
|00004b10| 28 49 6e 20 69 6d 70 6c | 65 6d 65 6e 74 61 74 69 |(In impl|ementati|
|00004b20| 6f 6e 73 20 69 6e 20 77 | 68 69 63 68 20 74 68 65 |ons in w|hich the|
|00004b30| 20 65 6d 70 74 79 0a 6c | 69 73 74 20 69 73 20 74 | empty.l|ist is t|
|00004b40| 68 65 20 73 61 6d 65 20 | 61 73 20 5c 73 63 68 66 |he same |as \schf|
|00004b50| 61 6c 73 65 7b 7d 2c 20 | 5c 69 64 65 7b 6e 75 6c |alse{}, |\ide{nul|
|00004b60| 6c 3f 7d 20 77 69 6c 6c | 20 72 65 74 75 72 6e 20 |l?} will| return |
|00004b70| 5c 73 63 68 74 72 75 65 | 7b 7d 0a 69 66 20 5c 76 |\schtrue|{}.if \v|
|00004b80| 61 72 7b 6f 62 6a 7d 20 | 69 73 20 5c 73 63 68 66 |ar{obj} |is \schf|
|00004b90| 61 6c 73 65 7b 7d 2e 29 | 20 0a 20 0a 5c 65 6e 64 |alse{}.)| . .\end|
|00004ba0| 7b 65 6e 74 72 79 7d 0a | 0a 0a 5c 62 65 67 69 6e |{entry}.|..\begin|
|00004bb0| 7b 65 6e 74 72 79 7d 7b | 25 0a 5c 70 72 6f 74 6f |{entry}{|%.\proto|
|00004bc0| 7b 6c 69 73 74 7d 7b 20 | 5c 76 61 72 7b 6f 62 6a |{list}{ |\var{obj|
|00004bd0| 7d 20 5c 64 6f 74 73 66 | 6f 6f 7d 7b 65 73 73 65 |} \dotsf|oo}{esse|
|00004be0| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00004bf0| 7d 0a 0a 52 65 74 75 72 | 6e 73 20 61 20 6c 69 73 |}..Retur|ns a lis|
|00004c00| 74 20 6f 66 20 69 74 73 | 20 61 72 67 75 6d 65 6e |t of its| argumen|
|00004c10| 74 73 2e 0a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |ts...\be|gin{sche|
|00004c20| 6d 65 7d 0a 28 6c 69 73 | 74 20 27 61 20 28 2b 20 |me}.(lis|t 'a (+ |
|00004c30| 33 20 34 29 20 27 63 29 | 20 20 20 20 20 20 20 20 |3 4) 'c)| |
|00004c40| 20 20 20 20 5c 65 76 20 | 20 28 61 20 37 20 63 29 | \ev | (a 7 c)|
|00004c50| 0a 28 6c 69 73 74 29 20 | 20 20 20 20 20 20 20 20 |.(list) | |
|00004c60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004c70| 20 5c 65 76 20 20 28 29 | 25 0a 5c 65 6e 64 7b 73 | \ev ()|%.\end{s|
|00004c80| 63 68 65 6d 65 7d 0a 5c | 65 6e 64 7b 65 6e 74 72 |cheme}.\|end{entr|
|00004c90| 79 7d 0a 0a 0a 5c 62 65 | 67 69 6e 7b 65 6e 74 72 |y}...\be|gin{entr|
|00004ca0| 79 7d 7b 25 0a 5c 70 72 | 6f 74 6f 7b 6c 65 6e 67 |y}{%.\pr|oto{leng|
|00004cb0| 74 68 7d 7b 20 6c 69 73 | 74 7d 7b 65 73 73 65 6e |th}{ lis|t}{essen|
|00004cc0| 74 69 61 6c 20 70 72 6f | 63 65 64 75 72 65 7d 7d |tial pro|cedure}}|
|00004cd0| 0a 0a 5c 6e 6f 64 6f 6d | 61 69 6e 7b 5c 76 61 72 |..\nodom|ain{\var|
|00004ce0| 7b 4c 69 73 74 7d 20 6d | 75 73 74 20 62 65 20 61 |{List} m|ust be a|
|00004cf0| 20 6c 69 73 74 2e 7d 0a | 52 65 74 75 72 6e 73 20 | list.}.|Returns |
|00004d00| 74 68 65 20 6c 65 6e 67 | 74 68 20 6f 66 20 5c 76 |the leng|th of \v|
|00004d10| 61 72 7b 6c 69 73 74 7d | 2e 0a 0a 5c 62 65 67 69 |ar{list}|...\begi|
|00004d20| 6e 7b 73 63 68 65 6d 65 | 7d 0a 28 6c 65 6e 67 74 |n{scheme|}.(lengt|
|00004d30| 68 20 27 28 61 20 62 20 | 63 29 29 20 20 20 20 20 |h '(a b |c)) |
|00004d40| 20 20 20 20 20 20 20 20 | 20 20 5c 65 76 20 20 33 | | \ev 3|
|00004d50| 0a 28 6c 65 6e 67 74 68 | 20 27 28 61 20 28 62 29 |.(length| '(a (b)|
|00004d60| 20 28 63 20 64 20 65 29 | 29 29 20 20 20 20 20 20 | (c d e)|)) |
|00004d70| 20 5c 65 76 20 20 33 0a | 28 6c 65 6e 67 74 68 20 | \ev 3.|(length |
|00004d80| 27 28 29 29 20 20 20 20 | 20 20 20 20 20 20 20 20 |'()) | |
|00004d90| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 30 25 0a | |\ev 0%.|
|00004da0| 5c 65 6e 64 7b 73 63 68 | 65 6d 65 7d 0a 5c 65 6e |\end{sch|eme}.\en|
|00004db0| 64 7b 65 6e 74 72 79 7d | 0a 0a 0a 5c 62 65 67 69 |d{entry}|...\begi|
|00004dc0| 6e 7b 65 6e 74 72 79 7d | 7b 25 0a 5c 70 72 6f 74 |n{entry}|{%.\prot|
|00004dd0| 6f 7b 61 70 70 65 6e 64 | 7d 7b 20 6c 69 73 74 20 |o{append|}{ list |
|00004de0| 5c 64 6f 74 73 66 6f 6f | 7d 7b 65 73 73 65 6e 74 |\dotsfoo|}{essent|
|00004df0| 69 61 6c 20 70 72 6f 63 | 65 64 75 72 65 7d 7d 0a |ial proc|edure}}.|
|00004e00| 0a 5c 6e 6f 64 6f 6d 61 | 69 6e 7b 41 6c 6c 20 5c |.\nodoma|in{All \|
|00004e10| 76 61 72 7b 6c 69 73 74 | 7d 73 20 73 68 6f 75 6c |var{list|}s shoul|
|00004e20| 64 20 62 65 20 6c 69 73 | 74 73 2e 7d 0a 52 65 74 |d be lis|ts.}.Ret|
|00004e30| 75 72 6e 73 20 61 20 6c | 69 73 74 20 63 6f 6e 73 |urns a l|ist cons|
|00004e40| 69 73 74 69 6e 67 20 6f | 66 20 74 68 65 20 65 6c |isting o|f the el|
|00004e50| 65 6d 65 6e 74 73 20 6f | 66 20 74 68 65 20 66 69 |ements o|f the fi|
|00004e60| 72 73 74 20 5c 76 61 72 | 7b 6c 69 73 74 7d 0a 66 |rst \var|{list}.f|
|00004e70| 6f 6c 6c 6f 77 65 64 20 | 62 79 20 74 68 65 20 65 |ollowed |by the e|
|00004e80| 6c 65 6d 65 6e 74 73 20 | 6f 66 20 74 68 65 20 6f |lements |of the o|
|00004e90| 74 68 65 72 20 5c 76 61 | 72 7b 6c 69 73 74 7d 73 |ther \va|r{list}s|
|00004ea0| 2e 0a 0a 5c 62 65 67 69 | 6e 7b 73 63 68 65 6d 65 |...\begi|n{scheme|
|00004eb0| 7d 0a 28 61 70 70 65 6e | 64 20 27 28 78 29 20 27 |}.(appen|d '(x) '|
|00004ec0| 28 79 29 29 20 20 20 20 | 20 20 20 20 20 20 20 20 |(y)) | |
|00004ed0| 20 20 5c 65 76 20 20 28 | 78 20 79 29 0a 28 61 70 | \ev (|x y).(ap|
|00004ee0| 70 65 6e 64 20 27 28 61 | 29 20 27 28 62 20 63 20 |pend '(a|) '(b c |
|00004ef0| 64 29 29 20 20 20 20 20 | 20 20 20 20 20 5c 65 76 |d)) | \ev|
|00004f00| 20 20 28 61 20 62 20 63 | 20 64 29 0a 28 61 70 70 | (a b c| d).(app|
|00004f10| 65 6e 64 20 27 28 61 20 | 28 62 29 29 20 27 28 28 |end '(a |(b)) '((|
|00004f20| 63 29 29 29 20 20 20 20 | 20 20 20 20 5c 65 76 20 |c))) | \ev |
|00004f30| 20 28 61 20 28 62 29 20 | 28 63 29 29 25 0a 5c 65 | (a (b) |(c))%.\e|
|00004f40| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 0a 54 68 65 20 |nd{schem|e}..The |
|00004f50| 72 65 73 75 6c 74 69 6e | 67 20 6c 69 73 74 20 69 |resultin|g list i|
|00004f60| 73 20 61 6c 77 61 79 73 | 20 6e 65 77 6c 79 20 61 |s always| newly a|
|00004f70| 6c 6c 6f 63 61 74 65 64 | 2c 20 65 78 63 65 70 74 |llocated|, except|
|00004f80| 20 74 68 61 74 20 69 74 | 20 73 68 61 72 65 73 0a | that it| shares.|
|00004f90| 73 74 72 75 63 74 75 72 | 65 20 77 69 74 68 20 74 |structur|e with t|
|00004fa0| 68 65 20 6c 61 73 74 20 | 5c 76 61 72 7b 6c 69 73 |he last |\var{lis|
|00004fb0| 74 7d 20 61 72 67 75 6d | 65 6e 74 2e 20 20 54 68 |t} argum|ent. Th|
|00004fc0| 65 20 6c 61 73 74 20 61 | 72 67 75 6d 65 6e 74 20 |e last a|rgument |
|00004fd0| 6d 61 79 0a 61 63 74 75 | 61 6c 6c 79 20 62 65 20 |may.actu|ally be |
|00004fe0| 61 6e 79 20 6f 62 6a 65 | 63 74 3b 20 61 6e 20 69 |any obje|ct; an i|
|00004ff0| 6d 70 72 6f 70 65 72 20 | 6c 69 73 74 20 72 65 73 |mproper |list res|
|00005000| 75 6c 74 73 20 69 66 20 | 69 74 20 69 73 20 6e 6f |ults if |it is no|
|00005010| 74 20 61 20 70 72 6f 70 | 65 72 0a 6c 69 73 74 2e |t a prop|er.list.|
|00005020| 20 20 5c 74 6f 64 6f 7b | 54 68 69 73 20 69 73 20 | \todo{|This is |
|00005030| 70 72 65 74 74 79 20 61 | 77 6b 77 61 72 64 2e 20 |pretty a|wkward. |
|00005040| 20 49 20 73 68 6f 75 6c | 64 20 67 65 74 20 42 61 | I shoul|d get Ba|
|00005050| 72 74 6c 65 79 20 74 6f | 20 66 69 78 20 74 68 69 |rtley to| fix thi|
|00005060| 73 2e 7d 0a 0a 5c 62 65 | 67 69 6e 7b 73 63 68 65 |s.}..\be|gin{sche|
|00005070| 6d 65 7d 0a 28 61 70 70 | 65 6e 64 20 27 28 61 20 |me}.(app|end '(a |
|00005080| 62 29 20 27 28 63 20 2e | 20 64 29 29 20 20 20 20 |b) '(c .| d)) |
|00005090| 20 20 20 20 5c 65 76 20 | 20 28 61 20 62 20 63 20 | \ev | (a b c |
|000050a0| 2e 20 64 29 0a 28 61 70 | 70 65 6e 64 20 27 28 29 |. d).(ap|pend '()|
|000050b0| 20 27 61 29 20 20 20 20 | 20 20 20 20 20 20 20 20 | 'a) | |
|000050c0| 20 20 20 20 20 5c 65 76 | 20 20 61 25 0a 5c 65 6e | \ev| a%.\en|
|000050d0| 64 7b 73 63 68 65 6d 65 | 7d 0a 5c 65 6e 64 7b 65 |d{scheme|}.\end{e|
|000050e0| 6e 74 72 79 7d 0a 0a 0a | 5c 62 65 67 69 6e 7b 65 |ntry}...|\begin{e|
|000050f0| 6e 74 72 79 7d 7b 25 0a | 5c 70 72 6f 74 6f 7b 72 |ntry}{%.|\proto{r|
|00005100| 65 76 65 72 73 65 7d 7b | 20 6c 69 73 74 7d 7b 65 |everse}{| list}{e|
|00005110| 73 73 65 6e 74 69 61 6c | 20 70 72 6f 63 65 64 75 |ssential| procedu|
|00005120| 72 65 7d 7d 0a 0a 5c 6e | 6f 64 6f 6d 61 69 6e 7b |re}}..\n|odomain{|
|00005130| 5c 76 61 72 7b 4c 69 73 | 74 7d 20 6d 75 73 74 20 |\var{Lis|t} must |
|00005140| 62 65 20 61 20 6c 69 73 | 74 2e 7d 0a 52 65 74 75 |be a lis|t.}.Retu|
|00005150| 72 6e 73 20 61 20 6e 65 | 77 6c 79 20 61 6c 6c 6f |rns a ne|wly allo|
|00005160| 63 61 74 65 64 20 6c 69 | 73 74 20 63 6f 6e 73 69 |cated li|st consi|
|00005170| 73 74 69 6e 67 20 6f 66 | 20 74 68 65 20 65 6c 65 |sting of| the ele|
|00005180| 6d 65 6e 74 73 20 6f 66 | 20 5c 76 61 72 7b 6c 69 |ments of| \var{li|
|00005190| 73 74 7d 0a 69 6e 20 72 | 65 76 65 72 73 65 20 6f |st}.in r|everse o|
|000051a0| 72 64 65 72 2e 0a 0a 5c | 62 65 67 69 6e 7b 73 63 |rder...\|begin{sc|
|000051b0| 68 65 6d 65 7d 0a 28 72 | 65 76 65 72 73 65 20 27 |heme}.(r|everse '|
|000051c0| 28 61 20 62 20 63 29 29 | 20 20 20 20 20 20 20 20 |(a b c))| |
|000051d0| 20 20 20 20 20 20 5c 65 | 76 20 20 28 63 20 62 20 | \e|v (c b |
|000051e0| 61 29 0a 28 72 65 76 65 | 72 73 65 20 27 28 61 20 |a).(reve|rse '(a |
|000051f0| 28 62 20 63 29 20 64 20 | 28 65 20 28 66 29 29 29 |(b c) d |(e (f)))|
|00005200| 29 20 20 5c 6c 65 76 20 | 20 28 28 65 20 28 66 29 |) \lev | ((e (f)|
|00005210| 29 20 64 20 28 62 20 63 | 29 20 61 29 25 0a 5c 65 |) d (b c|) a)%.\e|
|00005220| 6e 64 7b 73 63 68 65 6d | 65 7d 0a 5c 65 6e 64 7b |nd{schem|e}.\end{|
|00005230| 65 6e 74 72 79 7d 0a 0a | 0a 5c 62 65 67 69 6e 7b |entry}..|.\begin{|
|00005240| 65 6e 74 72 79 7d 7b 25 | 0a 5c 70 72 6f 74 6f 7b |entry}{%|.\proto{|
|00005250| 6c 69 73 74 2d 74 61 69 | 6c 7d 7b 20 6c 69 73 74 |list-tai|l}{ list|
|00005260| 20 5c 76 72 7b 6b 7d 7d | 7b 70 72 6f 63 65 64 75 | \vr{k}}|{procedu|
|00005270| 72 65 7d 7d 0a 0a 52 65 | 74 75 72 6e 73 20 74 68 |re}}..Re|turns th|
|00005280| 65 20 73 75 62 6c 69 73 | 74 20 6f 66 20 5c 76 61 |e sublis|t of \va|
|00005290| 72 7b 6c 69 73 74 7d 20 | 6f 62 74 61 69 6e 65 64 |r{list} |obtained|
|000052a0| 20 62 79 20 6f 6d 69 74 | 74 69 6e 67 20 74 68 65 | by omit|ting the|
|000052b0| 20 66 69 72 73 74 20 5c | 76 72 7b 6b 7d 0a 65 6c | first \|vr{k}.el|
|000052c0| 65 6d 65 6e 74 73 2e 0a | 5c 69 64 65 7b 4c 69 73 |ements..|\ide{Lis|
|000052d0| 74 2d 74 61 69 6c 7d 20 | 63 6f 75 6c 64 20 62 65 |t-tail} |could be|
|000052e0| 20 64 65 66 69 6e 65 64 | 20 62 79 0a 0a 5c 62 65 | defined| by..\be|
|000052f0| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 64 65 66 |gin{sche|me}.(def|
|00005300| 69 6e 65 20 6c 69 73 74 | 2d 74 61 69 6c 0a 20 20 |ine list|-tail. |
|00005310| 28 6c 61 6d 62 64 61 20 | 28 78 20 6b 29 0a 20 20 |(lambda |(x k). |
|00005320| 20 20 28 69 66 20 28 7a | 65 72 6f 3f 20 6b 29 0a | (if (z|ero? k).|
|00005330| 20 20 20 20 20 20 20 20 | 78 0a 20 20 20 20 20 20 | |x. |
|00005340| 20 20 28 6c 69 73 74 2d | 74 61 69 6c 20 28 63 64 | (list-|tail (cd|
|00005350| 72 20 78 29 20 28 2d 20 | 6b 20 31 29 29 29 29 29 |r x) (- |k 1)))))|
|00005360| 25 0a 5c 65 6e 64 7b 73 | 63 68 65 6d 65 7d 20 0a |%.\end{s|cheme} .|
|00005370| 5c 65 6e 64 7b 65 6e 74 | 72 79 7d 0a 0a 0a 5c 62 |\end{ent|ry}...\b|
|00005380| 65 67 69 6e 7b 65 6e 74 | 72 79 7d 7b 25 0a 5c 70 |egin{ent|ry}{%.\p|
|00005390| 72 6f 74 6f 7b 6c 69 73 | 74 2d 72 65 66 7d 7b 20 |roto{lis|t-ref}{ |
|000053a0| 6c 69 73 74 20 5c 76 72 | 7b 6b 7d 7d 7b 70 72 6f |list \vr|{k}}{pro|
|000053b0| 63 65 64 75 72 65 7d 7d | 0a 0a 52 65 74 75 72 6e |cedure}}|..Return|
|000053c0| 73 20 74 68 65 20 5c 76 | 72 7b 6b 7d 74 68 20 65 |s the \v|r{k}th e|
|000053d0| 6c 65 6d 65 6e 74 20 6f | 66 20 5c 76 61 72 7b 6c |lement o|f \var{l|
|000053e0| 69 73 74 7d 2e 20 20 28 | 54 68 69 73 20 69 73 20 |ist}. (|This is |
|000053f0| 74 68 65 20 73 61 6d 65 | 0a 61 73 20 74 68 65 20 |the same|.as the |
|00005400| 63 61 72 20 6f 66 20 7b | 5c 74 74 28 6c 69 73 74 |car of {|\tt(list|
|00005410| 2d 74 61 69 6c 20 5c 76 | 61 72 7b 6c 69 73 74 7d |-tail \v|ar{list}|
|00005420| 20 5c 76 72 7b 6b 7d 29 | 7d 2e 29 0a 0a 5c 62 65 | \vr{k})|}.)..\be|
|00005430| 67 69 6e 7b 73 63 68 65 | 6d 65 7d 0a 28 6c 69 73 |gin{sche|me}.(lis|
|00005440| 74 2d 72 65 66 20 27 28 | 61 20 62 20 63 20 64 29 |t-ref '(|a b c d)|
|00005450| 20 32 29 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | 2) | |
|00005460| 20 5c 65 76 20 20 63 25 | 0a 5c 65 6e 64 7b 73 63 | \ev c%|.\end{sc|
|00005470| 68 65 6d 65 7d 0a 5c 65 | 6e 64 7b 65 6e 74 72 79 |heme}.\e|nd{entry|
|00005480| 7d 0a 0a 0a 25 5c 62 65 | 67 69 6e 7b 65 6e 74 72 |}...%\be|gin{entr|
|00005490| 79 7d 7b 25 0a 25 5c 70 | 72 6f 74 6f 7b 6c 61 73 |y}{%.%\p|roto{las|
|000054a0| 74 2d 70 61 69 72 7d 7b | 20 6c 69 73 74 7d 7b 70 |t-pair}{| list}{p|
|000054b0| 72 6f 63 65 64 75 72 65 | 7d 7d 0a 25 0a 25 52 65 |rocedure|}}.%.%Re|
|000054c0| 74 75 72 6e 73 20 74 68 | 65 20 6c 61 73 74 20 70 |turns th|e last p|
|000054d0| 61 69 72 20 69 6e 20 74 | 68 65 20 6e 6f 6e 65 6d |air in t|he nonem|
|000054e0| 70 74 79 2c 20 70 6f 73 | 73 69 62 6c 79 20 69 6d |pty, pos|sibly im|
|000054f0| 70 72 6f 70 65 72 2c 20 | 6c 69 73 74 20 5c 76 61 |proper, |list \va|
|00005500| 72 7b 6c 69 73 74 7d 2e | 0a 25 5c 69 64 65 7b 4c |r{list}.|.%\ide{L|
|00005510| 61 73 74 2d 70 61 69 72 | 7d 20 63 6f 75 6c 64 20 |ast-pair|} could |
|00005520| 62 65 20 64 65 66 69 6e | 65 64 20 62 79 0a 25 0a |be defin|ed by.%.|
|00005530| 25 5c 62 65 67 69 6e 7b | 73 63 68 65 6d 65 7d 0a |%\begin{|scheme}.|
|00005540| 25 28 64 65 66 69 6e 65 | 20 6c 61 73 74 2d 70 61 |%(define| last-pa|
|00005550| 69 72 0a 25 20 20 28 6c | 61 6d 62 64 61 20 28 78 |ir.% (l|ambda (x|
|00005560| 29 0a 25 20 20 20 20 28 | 69 66 20 28 70 61 69 72 |).% (|if (pair|
|00005570| 3f 20 28 63 64 72 20 78 | 29 29 0a 25 20 20 20 20 |? (cdr x|)).% |
|00005580| 20 20 20 20 28 6c 61 73 | 74 2d 70 61 69 72 20 28 | (las|t-pair (|
|00005590| 63 64 72 20 78 29 29 0a | 25 20 20 20 20 20 20 20 |cdr x)).|% |
|000055a0| 20 78 29 29 29 25 0a 25 | 5c 65 6e 64 7b 73 63 68 | x)))%.%|\end{sch|
|000055b0| 65 6d 65 7d 20 0a 25 20 | 0a 25 5c 65 6e 64 7b 65 |eme} .% |.%\end{e|
|000055c0| 6e 74 72 79 7d 0a 0a 0a | 5c 62 65 67 69 6e 7b 65 |ntry}...|\begin{e|
|000055d0| 6e 74 72 79 7d 7b 25 0a | 5c 70 72 6f 74 6f 7b 6d |ntry}{%.|\proto{m|
|000055e0| 65 6d 71 7d 7b 20 6f 62 | 6a 20 6c 69 73 74 7d 7b |emq}{ ob|j list}{|
|000055f0| 65 73 73 65 6e 74 69 61 | 6c 20 70 72 6f 63 65 64 |essentia|l proced|
|00005600| 75 72 65 7d 0a 5c 70 72 | 6f 74 6f 7b 6d 65 6d 76 |ure}.\pr|oto{memv|
|00005610| 7d 7b 20 6f 62 6a 20 6c | 69 73 74 7d 7b 65 73 73 |}{ obj l|ist}{ess|
|00005620| 65 6e 74 69 61 6c 20 70 | 72 6f 63 65 64 75 72 65 |ential p|rocedure|
|00005630| 7d 0a 5c 70 72 6f 74 6f | 7b 6d 65 6d 62 65 72 7d |}.\proto|{member}|
|00005640| 7b 20 6f 62 6a 20 6c 69 | 73 74 7d 7b 65 73 73 65 |{ obj li|st}{esse|
|00005650| 6e 74 69 61 6c 20 70 72 | 6f 63 65 64 75 72 65 7d |ntial pr|ocedure}|
|00005660| 7d 0a 0a 25 46 69 6e 64 | 73 20 74 68 65 20 66 69 |}..%Find|s the fi|
|00005670| 72 73 74 20 6f 63 63 75 | 72 72 65 6e 63 65 20 6f |rst occu|rrence o|
|00005680| 66 20 5c 76 61 72 7b 6f | 62 6a 7d 20 69 6e 20 74 |f \var{o|bj} in t|
|00005690| 68 65 20 6c 69 73 74 20 | 5c 76 61 72 7b 6c 69 73 |he list |\var{lis|
|000056a0| 74 7d 20 61 6e 64 0a 54 | 68 65 73 65 20 70 72 6f |t} and.T|hese pro|
|000056b0| 63 65 64 75 72 65 73 20 | 72 65 74 75 72 6e 20 74 |cedures |return t|
|000056c0| 68 65 20 66 69 72 73 74 | 20 73 75 62 6c 69 73 74 |he first| sublist|
|000056d0| 20 6f 66 20 5c 76 61 72 | 7b 6c 69 73 74 7d 20 77 | of \var|{list} w|
|000056e0| 68 6f 73 65 20 63 61 72 | 20 69 73 0a 5c 76 61 72 |hose car| is.\var|
|000056f0| 7b 6f 62 6a 7d 2e 20 20 | 49 66 20 5c 76 61 72 7b |{obj}. |If \var{|
|00005700| 6f 62 6a 7d 20 64 6f 65 | 73 20 6e 6f 74 20 6f 63 |obj} doe|s not oc|
|00005710| 63 75 72 20 69 6e 20 5c | 76 61 72 7b 6c 69 73 74 |cur in \|var{list|
|00005720| 7d 2c 20 5c 73 63 68 66 | 61 6c 73 65 7b 7d 0a 28 |}, \schf|alse{}.(|
|00005730| 6e 2e 62 2e 3a 7e 6e 6f | 74 20 74 68 65 20 65 6d |n.b.:~no|t the em|
|00005740| 70 74 79 20 6c 69 73 74 | 29 20 69 73 20 72 65 74 |pty list|) is ret|
|00005750| 75 72 6e 65 64 2e 20 20 | 5c 69 64 65 7b 4d 65 6d |urned. |\ide{Mem|
|00005760| 71 7d 20 75 73 65 73 20 | 5c 69 64 65 7b 65 71 3f |q} uses |\ide{eq?|
|00005770| 7d 5c 20 74 6f 0a 63 6f | 6d 70 61 72 65 20 5c 76 |}\ to.co|mpare \v|
|00005780| 61 72 7b 6f 62 6a 7d 20 | 77 69 74 68 20 74 68 65 |ar{obj} |with the|
|00005790| 20 65 6c 65 6d 65 6e 74 | 73 20 6f 66 20 5c 76 61 | element|s of \va|
|000057a0| 72 7b 6c 69 73 74 7d 2c | 20 77 68 69 6c 65 20 5c |r{list},| while \|
|000057b0| 69 64 65 7b 6d 65 6d 76 | 7d 20 75 73 65 73 0a 5c |ide{memv|} uses.\|
|000057c0| 69 64 65 7b 65 71 76 3f | 7d 5c 20 61 6e 64 20 5c |ide{eqv?|}\ and \|
|000057d0| 69 64 65 7b 6d 65 6d 62 | 65 72 7d 20 75 73 65 73 |ide{memb|er} uses|
|000057e0| 20 5c 69 64 65 7b 65 71 | 75 61 6c 3f 7d 2e 0a 0a | \ide{eq|ual?}...|
|000057f0| 5c 62 65 67 69 6e 7b 73 | 63 68 65 6d 65 7d 0a 28 |\begin{s|cheme}.(|
|00005800| 6d 65 6d 71 20 27 61 20 | 27 28 61 20 62 20 63 29 |memq 'a |'(a b c)|
|00005810| 29 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5c |) | \|
|00005820| 65 76 20 20 28 61 20 62 | 20 63 29 0a 28 6d 65 6d |ev (a b| c).(mem|
|00005830| 71 20 27 62 20 27 28 61 | 20 62 20 63 29 29 20 20 |q 'b '(a| b c)) |
|00005840| 20 20 20 20 20 20 20 20 | 20 20 20 20 5c 65 76 20 | | \ev |
|00005850| 20 28 62 20 63 29 0a 28 | 6d 65 6d 71 20 27 61 20 | (b c).(|memq 'a |
|00005860| 27 28 62 20 63 20 64 29 | 29 20 20 20 20 20 20 20 |'(b c d)|) |
|00005870| 20 20 20 20 20 20 20 5c | 65 76 20 20 5c 73 63 68 | \|ev \sch|
|00005880| 66 61 6c 73 65 0a 28 6d | 65 6d 71 20 28 6c 69 73 |false.(m|emq (lis|
|00005890| 74 20 27 61 29 20 27 28 | 62 20 28 61 29 20 63 29 |t 'a) '(|b (a) c)|
|000058a0| 29 20 20 20 20 20 5c 65 | 76 20 20 5c 73 63 68 66 |) \e|v \schf|
|000058b0| 61 6c 73 65 0a 28 6d 65 | 6d 62 65 72 20 28 6c 69 |alse.(me|mber (li|
|000058c0| 73 74 20 27 61 29 0a 20 | 20 20 20 20 20 20 20 27 |st 'a). | '|
|000058d0| 28 62 20 28 61 29 20 63 | 29 29 20 20 20 20 20 20 |(b (a) c|)) |
|000058e0| 20 20 20 20 20 20 20 5c | 65 76 20 20 28 28 61 29 | \|ev ((a)|
|000058f0| 20 63 29 0a 28 6d 65 6d | 71 20 31 30 31 20 27 28 | c).(mem|q 101 '(|
|00005900| 31 30 30 20 31 30 31 20 | 31 30 32 29 29 20 20 20 |100 101 |102)) |
|00005910| 20 20 20 20 5c 65 76 20 | 20 5c 75 6e 73 70 65 63 | \ev | \unspec|
|00005920| 69 66 69 65 64 0a 28 6d | 65 6d 76 20 31 30 31 20 |ified.(m|emv 101 |
|00005930| 27 28 31 30 30 20 31 30 | 31 20 31 30 32 29 29 20 |'(100 10|1 102)) |
|00005940| 20 20 20 20 20 20 5c 65 | 76 20 20 28 31 30 31 20 | \e|v (101 |
|00005950| 31 30 32 29 25 0a 5c 65 | 6e 64 7b 73 63 68 65 6d |102)%.\e|nd{schem|
|00005960| 65 7d 20 0a 20 0a 5c 65 | 6e 64 7b 65 6e 74 72 79 |e} . .\e|nd{entry|
|00005970| 7d 0a 0a 0a 5c 62 65 67 | 69 6e 7b 65 6e 74 72 79 |}...\beg|in{entry|
|00005980| 7d 7b 25 0a 5c 70 72 6f | 74 6f 7b 61 73 73 71 7d |}{%.\pro|to{assq}|
|00005990| 7b 20 6f 62 6a 20 61 6c | 69 73 74 7d 7b 65 73 73 |{ obj al|ist}{ess|
|000059a0| 65 6e 74 69 61 6c 20 70 | 72 6f 63 65 64 75 72 65 |ential p|rocedure|
|000059b0| 7d 0a 5c 70 72 6f 74 6f | 7b 61 73 73 76 7d 7b 20 |}.\proto|{assv}{ |
|000059c0| 6f 62 6a 20 61 6c 69 73 | 74 7d 7b 65 73 73 65 6e |obj alis|t}{essen|
|000059d0| 74 69 61 6c 20 70 72 6f | 63 65 64 75 72 65 7d 0a |tial pro|cedure}.|
|000059e0| 5c 70 72 6f 74 6f 7b 61 | 73 73 6f 63 7d 7b 20 6f |\proto{a|ssoc}{ o|
|000059f0| 62 6a 20 61 6c 69 73 74 | 7d 7b 65 73 73 65 6e 74 |bj alist|}{essent|
|00005a00| 69 61 6c 20 70 72 6f 63 | 65 64 75 72 65 7d 7d 0a |ial proc|edure}}.|
|00005a10| 0a 5c 64 6f 6d 61 69 6e | 7b 5c 76 61 72 7b 41 6c |.\domain|{\var{Al|
|00005a20| 69 73 74 7d 20 28 66 6f | 72 20 60 60 61 73 73 6f |ist} (fo|r ``asso|
|00005a30| 63 69 61 74 69 6f 6e 20 | 6c 69 73 74 27 27 29 20 |ciation |list'') |
|00005a40| 6d 75 73 74 20 62 65 20 | 61 20 6c 69 73 74 20 6f |must be |a list o|
|00005a50| 66 0a 70 61 69 72 73 2e | 7d 20 20 54 68 65 73 65 |f.pairs.|} These|
|00005a60| 20 70 72 6f 63 65 64 75 | 72 65 73 20 66 69 6e 64 | procedu|res find|
|00005a70| 20 74 68 65 20 66 69 72 | 73 74 20 70 61 69 72 20 | the fir|st pair |
|00005a80| 69 6e 20 5c 76 61 72 7b | 61 6c 69 73 74 7d 20 77 |in \var{|alist} w|
|00005a90| 68 6f 73 65 20 63 61 72 | 20 66 69 65 6c 64 20 69 |hose car| field i|
|00005aa0| 73 20 5c 76 61 72 7b 6f | 62 6a 7d 2c 0a 61 6e 64 |s \var{o|bj},.and|
|00005ab0| 20 72 65 74 75 72 6e 73 | 20 74 68 61 74 20 70 61 | returns| that pa|
|00005ac0| 69 72 2e 20 20 49 66 20 | 6e 6f 20 70 61 69 72 20 |ir. If |no pair |
|00005ad0| 69 6e 20 5c 76 61 72 7b | 61 6c 69 73 74 7d 20 68 |in \var{|alist} h|
|00005ae0| 61 73 20 5c 76 61 72 7b | 6f 62 6a 7d 20 61 73 20 |as \var{|obj} as |
|00005af0| 69 74 73 0a 63 61 72 2c | 20 5c 73 63 68 66 61 6c |its.car,| \schfal|
|00005b00| 73 65 7b 7d 20 69 73 20 | 72 65 74 75 72 6e 65 64 |se{} is |returned|
|00005b10| 2e 20 20 5c 69 64 65 7b | 41 73 73 71 7d 20 75 73 |. \ide{|Assq} us|
|00005b20| 65 73 20 5c 69 64 65 7b | 65 71 3f 7d 5c 20 74 6f |es \ide{|eq?}\ to|
|00005b30| 20 63 6f 6d 70 61 72 65 | 20 5c 76 61 72 7b 6f 62 | compare| \var{ob|
|00005b40| 6a 7d 0a 77 69 74 68 20 | 74 68 65 20 63 61 72 20 |j}.with |the car |
|00005b50| 66 69 65 6c 64 73 20 6f | 66 20 74 68 65 20 70 61 |fields o|f the pa|
|00005b60| 69 72 73 20 69 6e 20 5c | 76 61 72 7b 61 6c 69 73 |irs in \|var{alis|
|00005b70| 74 7d 2c 20 77 68 69 6c | 65 20 5c 69 64 65 7b 61 |t}, whil|e \ide{a|
|00005b80| 73 73 76 7d 20 75 73 65 | 73 0a 5c 69 64 65 7b 65 |ssv} use|s.\ide{e|
|00005b90| 71 76 3f 7d 5c 20 61 6e | 64 20 5c 69 64 65 7b 61 |qv?}\ an|d \ide{a|
|00005ba0| 73 73 6f 63 7d 20 75 73 | 65 73 20 5c 69 64 65 7b |ssoc} us|es \ide{|
|00005bb0| 65 71 75 61 6c 3f 7d 2e | 0a 0a 5c 62 65 67 69 6e |equal?}.|..\begin|
|00005bc0| 7b 73 63 68 65 6d 65 7d | 0a 28 64 65 66 69 6e 65 |{scheme}|.(define|
|00005bd0| 20 65 20 27 28 28 61 20 | 31 29 20 28 62 20 32 29 | e '((a |1) (b 2)|
|00005be0| 20 28 63 20 33 29 29 29 | 0a 28 61 73 73 71 20 27 | (c 3)))|.(assq '|
|00005bf0| 61 20 65 29 20 20 20 20 | 20 5c 65 76 20 20 28 61 |a e) | \ev (a|
|00005c00| 20 31 29 0a 28 61 73 73 | 71 20 27 62 20 65 29 20 | 1).(ass|q 'b e) |
|00005c10| 20 20 20 20 5c 65 76 20 | 20 28 62 20 32 29 0a 28 | \ev | (b 2).(|
|00005c20| 61 73 73 71 20 27 64 20 | 65 29 20 20 20 20 20 5c |assq 'd |e) \|
|00005c30| 65 76 20 20 5c 73 63 68 | 66 61 6c 73 65 0a 28 61 |ev \sch|false.(a|
|00005c40| 73 73 71 20 28 6c 69 73 | 74 20 27 61 29 20 27 28 |ssq (lis|t 'a) '(|
|00005c50| 28 28 61 29 29 20 28 28 | 62 29 29 20 28 28 63 29 |((a)) ((|b)) ((c)|
|00005c60| 29 29 29 0a 20 20 20 20 | 20 20 20 20 20 20 20 20 |))). | |
|00005c70| 20 20 20 20 5c 65 76 20 | 20 5c 73 63 68 66 61 6c | \ev | \schfal|
|00005c80| 73 65 0a 28 61 73 73 6f | 63 20 28 6c 69 73 74 20 |se.(asso|c (list |
|00005c90| 27 61 29 20 27 28 28 28 | 61 29 29 20 28 28 62 29 |'a) '(((|a)) ((b)|
|00005ca0| 29 20 28 28 63 29 29 29 | 29 20 20 20 0a 20 20 20 |) ((c)))|) . |
|00005cb0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005cc0| 20 20 20 20 20 20 20 20 | 5c 65 76 20 20 28 28 61 | |\ev ((a|
|00005cd0| 29 29 0a 28 61 73 73 71 | 20 35 20 27 28 28 32 20 |)).(assq| 5 '((2 |
|00005ce0| 33 29 20 28 35 20 37 29 | 20 28 31 31 20 31 33 29 |3) (5 7)| (11 13)|
|00005cf0| 29 29 20 20 20 20 0a 20 | 20 20 20 20 20 20 20 20 |)) . | |
|00005d00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005d10| 20 20 5c 65 76 20 20 5c | 75 6e 73 70 65 63 69 66 | \ev \|unspecif|
|00005d20| 69 65 64 0a 28 61 73 73 | 76 20 35 20 27 28 28 32 |ied.(ass|v 5 '((2|
|00005d30| 20 33 29 20 28 35 20 37 | 29 20 28 31 31 20 31 33 | 3) (5 7|) (11 13|
|00005d40| 29 29 29 20 20 20 20 0a | 20 20 20 20 20 20 20 20 |))) .| |
|00005d50| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005d60| 20 20 20 5c 65 76 20 20 | 28 35 20 37 29 25 0a 5c | \ev |(5 7)%.\|
|00005d70| 65 6e 64 7b 73 63 68 65 | 6d 65 7d 0a 0a 0a 5c 62 |end{sche|me}...\b|
|00005d80| 65 67 69 6e 7b 6e 6f 74 | 65 7d 0a 41 6c 74 68 6f |egin{not|e}.Altho|
|00005d90| 75 67 68 20 74 68 65 79 | 20 61 72 65 20 6f 72 64 |ugh they| are ord|
|00005da0| 69 6e 61 72 69 6c 79 20 | 75 73 65 64 20 61 73 20 |inarily |used as |
|00005db0| 70 72 65 64 69 63 61 74 | 65 73 2c 0a 5c 69 64 65 |predicat|es,.\ide|
|00005dc0| 7b 6d 65 6d 71 7d 2c 20 | 5c 69 64 65 7b 6d 65 6d |{memq}, |\ide{mem|
|00005dd0| 76 7d 2c 20 5c 69 64 65 | 7b 6d 65 6d 62 65 72 7d |v}, \ide|{member}|
|00005de0| 2c 20 5c 69 64 65 7b 61 | 73 73 71 7d 2c 20 5c 69 |, \ide{a|ssq}, \i|
|00005df0| 64 65 7b 61 73 73 76 7d | 2c 20 61 6e 64 20 5c 69 |de{assv}|, and \i|
|00005e00| 64 65 7b 61 73 73 6f 63 | 7d 20 64 6f 20 6e 6f 74 |de{assoc|} do not|
|00005e10| 0a 68 61 76 65 20 71 75 | 65 73 74 69 6f 6e 20 6d |.have qu|estion m|
|00005e20| 61 72 6b 73 20 69 6e 20 | 74 68 65 69 72 20 6e 61 |arks in |their na|
|00005e30| 6d 65 73 20 62 65 63 61 | 75 73 65 20 74 68 65 79 |mes beca|use they|
|00005e40| 20 72 65 74 75 72 6e 20 | 75 73 65 66 75 6c 20 76 | return |useful v|
|00005e50| 61 6c 75 65 73 20 72 61 | 74 68 65 72 0a 74 68 61 |alues ra|ther.tha|
|00005e60| 6e 20 6a 75 73 74 20 5c | 73 63 68 74 72 75 65 7b |n just \|schtrue{|
|00005e70| 7d 20 6f 72 20 5c 73 63 | 68 66 61 6c 73 65 7b 7d |} or \sc|hfalse{}|
|00005e80| 2e 0a 5c 65 6e 64 7b 6e | 6f 74 65 7d 0a 5c 65 6e |..\end{n|ote}.\en|
|00005e90| 64 7b 65 6e 74 72 79 7d | 0a 0a 0a 5c 73 65 63 74 |d{entry}|...\sect|
|00005ea0| 69 6f 6e 7b 53 79 6d 62 | 6f 6c 73 7d 0a 5c 6c 61 |ion{Symb|ols}.\la|
|00005eb0| 62 65 6c 7b 73 79 6d 62 | 6f 6c 73 65 63 74 69 6f |bel{symb|olsectio|
|00005ec0| 6e 7d 0a 0a 53 79 6d 62 | 6f 6c 73 20 61 72 65 20 |n}..Symb|ols are |
|00005ed0| 6f 62 6a 65 63 74 73 20 | 77 68 6f 73 65 20 75 73 |objects |whose us|
|00005ee0| 65 66 75 6c 6e 65 73 73 | 20 72 65 73 74 73 20 6f |efulness| rests o|
|00005ef0| 6e 20 74 68 65 20 66 61 | 63 74 20 74 68 61 74 20 |n the fa|ct that |
|00005f00| 74 77 6f 0a 73 79 6d 62 | 6f 6c 73 20 61 72 65 20 |two.symb|ols are |
|00005f10| 69 64 65 6e 74 69 63 61 | 6c 20 28 69 6e 20 74 68 |identica|l (in th|
|00005f20| 65 20 73 65 6e 73 65 20 | 6f 66 20 5c 69 64 65 7b |e sense |of \ide{|
|00005f30| 65 71 76 3f 7d 29 20 69 | 66 20 61 6e 64 20 6f 6e |eqv?}) i|f and on|
|00005f40| 6c 79 20 69 66 20 74 68 | 65 69 72 0a 6e 61 6d 65 |ly if th|eir.name|
|00005f50| 73 20 61 72 65 20 73 70 | 65 6c 6c 65 64 20 74 68 |s are sp|elled th|
|00005f60| 65 20 73 61 6d 65 20 77 | 61 79 2e 20 20 54 68 69 |e same w|ay. Thi|
|00005f70| 73 20 69 73 20 65 78 61 | 63 74 6c 79 20 74 68 65 |s is exa|ctly the|
|00005f80| 20 70 72 6f 70 65 72 74 | 79 20 6e 65 65 64 65 64 | propert|y needed|
|00005f90| 20 74 6f 0a 72 65 70 72 | 65 73 65 6e 74 20 69 64 | to.repr|esent id|
|00005fa0| 65 6e 74 69 66 69 65 72 | 73 5c 69 6e 64 65 78 7b |entifier|s\index{|
|00005fb0| 69 64 65 6e 74 69 66 69 | 65 72 7d 20 69 6e 20 70 |identifi|er} in p|
|00005fc0| 72 6f 67 72 61 6d 73 2c | 20 61 6e 64 20 73 6f 20 |rograms,| and so |
|00005fd0| 6d 6f 73 74 0a 69 6d 70 | 6c 65 6d 65 6e 74 61 74 |most.imp|lementat|
|00005fe0| 69 6f 6e 73 20 6f 66 20 | 53 63 68 65 6d 65 20 75 |ions of |Scheme u|
|00005ff0| 73 65 20 74 68 65 6d 20 | 69 6e 74 65 72 6e 61 6c |se them |internal|
|00006000| 6c 79 20 66 6f 72 20 74 | 68 61 74 20 70 75 72 70 |ly for t|hat purp|
|00006010| 6f 73 65 2e 20 20 53 79 | 6d 62 6f 6c 73 0a 61 72 |ose. Sy|mbols.ar|
|00006020| 65 20 75 73 65 66 75 6c | 20 66 6f 72 20 6d 61 6e |e useful| for man|
|00006030| 79 20 6f 74 68 65 72 20 | 61 70 70 6c 69 63 61 74 |y other |applicat|
|00006040| 69 6f 6e 73 3b 20 66 6f | 72 20 69 6e 73 74 61 6e |ions; fo|r instan|
|00006050| 63 65 2c 20 74 68 65 79 | 20 6d 61 79 20 62 65 20 |ce, they| may be |
|00006060| 75 73 65 64 0a 74 68 65 | 20 77 61 79 20 65 6e 75 |used.the| way enu|
|00006070| 6d 65 72 61 74 65 64 20 | 76 61 6c 75 65 73 20 61 |merated |values a|
|00006080| 72 65 20 75 73 65 64 20 | 69 6e 20 50 61 73 63 61 |re used |in Pasca|
|00006090| 6c 2e 0a 0a 5c 76 65 73 | 74 20 54 68 65 20 72 75 |l...\ves|t The ru|
|000060a0| 6c 65 73 20 66 6f 72 20 | 77 72 69 74 69 6e 67 20 |les for |writing |
|000060b0| 61 20 73 79 6d 62 6f 6c | 20 61 72 65 20 65 78 61 |a symbol| are exa|
|000060c0| 63 74 6c 79 20 74 68 65 | 20 73 61 6d 65 20 61 73 |ctly the| same as|
|000060d0| 20 74 68 65 20 72 75 6c | 65 73 20 66 6f 72 0a 77 | the rul|es for.w|
|000060e0| 72 69 74 69 6e 67 20 61 | 6e 20 69 64 65 6e 74 69 |riting a|n identi|
|000060f0| 66 69 65 72 3b 20 73 65 | 65 20 73 65 63 74 69 6f |fier; se|e sectio|
|00006100| 6e 73 7e 5c 72 65 66 7b | 73 79 6e 74 61 78 73 65 |ns~\ref{|syntaxse|
|00006110| 63 74 69 6f 6e 7d 0a 61 | 6e 64 7e 5c 72 65 66 7b |ction}.a|nd~\ref{|
|00006120| 69 64 65 6e 74 69 66 69 | 65 72 73 79 6e 74 61 78 |identifi|ersyntax|
|00006130| 7d 2e 0a 0a 5c 76 65 73 | 74 20 49 74 20 69 73 20 |}...\ves|t It is |
|00006140| 67 75 61 72 61 6e 74 65 | 65 64 20 74 68 61 74 20 |guarante|ed that |
|00006150| 61 6e 79 20 73 79 6d 62 | 6f 6c 20 74 68 61 74 20 |any symb|ol that |
|00006160| 68 61 73 20 62 65 65 6e | 20 72 65 74 75 72 6e 65 |has been| returne|
|00006170| 64 20 61 73 20 70 61 72 | 74 20 6f 66 0a 61 20 6c |d as par|t of.a l|
|00006180| 69 74 65 72 61 6c 20 65 | 78 70 72 65 73 73 69 6f |iteral e|xpressio|
|00006190| 6e 2c 20 6f 72 20 72 65 | 61 64 20 75 73 69 6e 67 |n, or re|ad using|
|000061a0| 20 74 68 65 20 5c 69 64 | 65 7b 72 65 61 64 7d 20 | the \id|e{read} |
|000061b0| 70 72 6f 63 65 64 75 72 | 65 2c 20 61 6e 64 0a 73 |procedur|e, and.s|
|000061c0| 75 62 73 65 71 75 65 6e | 74 6c 79 20 77 72 69 74 |ubsequen|tly writ|
|000061d0| 74 65 6e 20 6f 75 74 20 | 75 73 69 6e 67 20 74 68 |ten out |using th|
|000061e0| 65 20 5c 69 64 65 7b 77 | 72 69 74 65 7d 20 70 72 |e \ide{w|rite} pr|
|000061f0| 6f 63 65 64 75 72 65 2c | 20 77 69 6c 6c 20 72 65 |ocedure,| will re|
|00006200| 61 64 20 62 61 63 6b 0a | 69 6e 20 61 73 20 74 68 |ad back.|in as th|
|00006210| 65 20 69 64 65 6e 74 69 | 63 61 6c 20 73 79 6d 62 |e identi|cal symb|
|00006220| 6f 6c 20 28 69 6e 20 74 | 68 65 20 73 65 6e 73 65 |ol (in t|he sense|
|00006230| 20 6f 66 20 5c 69 64 65 | 7b 65 71 76 3f 7d 29 2e | of \ide|{eqv?}).|
|00006240| 20 20 54 68 65 0a 5c 69 | 64 65 7b 73 74 72 69 6e | The.\i|de{strin|
|00006250| 67 5c 63 6f 65 72 63 65 | 7b 7d 73 79 6d 62 6f 6c |g\coerce|{}symbol|
|00006260| 7d 20 70 72 6f 63 65 64 | 75 72 65 2c 20 68 6f 77 |} proced|ure, how|
|00006270| 65 76 65 72 2c 20 63 61 | 6e 20 63 72 65 61 74 65 |ever, ca|n create|
|00006280| 20 73 79 6d 62 6f 6c 73 | 20 66 6f 72 0a 77 68 69 | symbols| for.whi|
|00006290| 63 68 20 74 68 69 73 20 | 77 72 69 74 65 2f 72 65 |ch this |write/re|
|000062a0| 61 64 20 69 6e 76 61 72 | 69 61 6e 63 65 20 6d 61 |ad invar|iance ma|
|000062b0| 79 20 6e 6f 74 20 68 6f | 6c 64 20 62 65 63 61 75 |y not ho|ld becau|
|000062c0| 73 65 20 74 68 65 69 72 | 20 6e 61 6d 65 73 0a 63 |se their| names.c|
|000062d0| 6f 6e 74 61 69 6e 20 73 | 70 65 63 69 61 6c 20 63 |ontain s|pecial c|
|000062e0| 68 61 72 61 63 74 65 72 | 73 20 6f 72 20 6c 65 74 |haracter|s or let|
|000062f0| 74 65 72 73 20 69 6e 20 | 74 68 65 20 6e 6f 6e 2d |ters in |the non-|
|00006300| 73 74 61 6e 64 61 72 64 | 20 63 61 73 65 2e 0a 0a |standard| case...|
|00006310| 5c 62 65 67 69 6e 7b 6e | 6f 74 65 7d 0a 53 6f 6d |\begin{n|ote}.Som|
|00006320| 65 20 69 6d 70 6c 65 6d | 65 6e 74 61 74 69 6f 6e |e implem|entation|
|00006330| 73 20 6f 66 20 53 63 68 | 65 6d 65 20 68 61 76 65 |s of Sch|eme have|
|00006340| 20 61 20 66 65 61 74 75 | 72 65 20 6b 6e 6f 77 6e | a featu|re known|
|00006350| 20 61 73 20 60 60 73 6c | 61 73 68 69 66 69 63 61 | as ``sl|ashifica|
|00006360| 74 69 6f 6e 27 27 0a 69 | 6e 20 6f 72 64 65 72 20 |tion''.i|n order |
|00006370| 74 6f 20 67 75 61 72 61 | 6e 74 65 65 20 77 72 69 |to guara|ntee wri|
|00006380| 74 65 2f 72 65 61 64 20 | 69 6e 76 61 72 69 61 6e |te/read |invarian|
|00006390| 63 65 20 66 6f 72 20 61 | 6c 6c 20 73 79 6d 62 6f |ce for a|ll symbo|
|000063a0| 6c 73 2c 20 62 75 74 0a | 68 69 73 74 6f 72 69 63 |ls, but.|historic|
|000063b0| 61 6c 6c 79 20 74 68 65 | 20 6d 6f 73 74 20 69 6d |ally the| most im|
|000063c0| 70 6f 72 74 61 6e 74 20 | 75 73 65 20 6f 66 20 74 |portant |use of t|
|000063d0| 68 69 73 20 66 65 61 74 | 75 72 65 20 68 61 73 20 |his feat|ure has |
|000063e0| 62 65 65 6e 20 74 6f 0a | 63 6f 6d 70 65 6e 73 61 |been to.|compensa|
|000063f0| 74 65 20 66 6f 72 20 74 | 68 65 20 6c 61 63 6b 20 |te for t|he lack |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.